Re: [PATCH v3/resubmit 1/3] staging: gs_fpgaboot: add buffer overflow checks

2017-07-27 Thread Greg Kroah-Hartman
On Wed, Jul 26, 2017 at 09:13:57PM -0400, Jacob von Chorus wrote:
> Four fields in struct fpgaimage are char arrays of length MAX_STR (256).
> The amount of data read into these buffers is controlled by a length
> field in the bitstream file read from userspace. If a corrupt or
> malicious firmware file was supplied, kernel data beyond these buffers
> can be overwritten arbitrarily.
> 
> This patch adds a check of the bitstream's length value to ensure it
> fits within the bounds of the allocated buffers. An error condition is
> returned from gs_read_bitstream if any of the reads fail.
> 
> Signed-off-by: Jacob von Chorus 
> 
> v3:
> - use >= to prevent an integer overflow in the comparison
> - use get_unaligned_be functions to interpret length fields
> - fix remainder of file to use valid error codes
> 
> v2:
> - char arrays converted to u8 arrays
> - replace error return value with proper error code in
>   gs_read_bitstream
> ---

All of the v2: and such needs to go below the --- line, as
Documentation/SubmittingPatches says to do.

Please fix that up and resend the series.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: ccree: Replace kzalloc with devm_kzalloc

2017-07-27 Thread Greg Kroah-Hartman
On Thu, Jul 27, 2017 at 05:27:32PM +0300, Gilad Ben-Yossef wrote:
> From: Suniel Mahesh 
> 
> It is recommended to use managed function devm_kzalloc, which
> simplifies driver cleanup paths and driver code.
> This patch does the following:
> (a) replace kzalloc with devm_kzalloc.
> (b) drop kfree(), because memory allocated with devm_kzalloc() is
> automatically freed on driver detach, otherwise it leads to a double
> free.
> (c) remove unnecessary blank lines.
> 
> Signed-off-by: Suniel Mahesh 
> [gby: rebase on top of latest coding style fixes changes]
> Acked-by: Gilad Ben-Yossef 

None of these 3 applied to my tree :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/4] staging: ccree: coding style clean ups

2017-07-27 Thread Greg Kroah-Hartman
On Thu, Jul 27, 2017 at 01:43:14PM +0300, Gilad Ben-Yossef wrote:
> Misc. coding style fixes for ccree driver.
> 
> These are the missing patches that failed to apply two weeks ago,
> rebased onto latest staging-next.
> 
> By the way, I still do not understand why they failed to apply,
> as they applied just fine being cherry picked on top of latest
> staging-next apart for fixes for later changes. I hope these will
> be good.

Only one applied here :(

I did just take some more coding style fixes from someone else who sent
them before you did as they looked correct, maybe that's why?  Can you
rebase and resend?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8188eu: Fix coding style issue for braces

2017-07-27 Thread Greg KH
On Thu, Jul 27, 2017 at 09:33:45AM -0500, Deb McLemore wrote:
> checkpatch.pl open brace following function declaration goes on
> next line so fix the brace to go properly on next line
> 
> Signed-off-by: Deb McLemore 
> ---
>  drivers/staging/rtl8188eu/include/rtw_ioctl.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h 
> b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
> index 0fa78ed..4c925e6 100644
> --- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h
> +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
> @@ -75,7 +75,8 @@ struct oid_par_priv {
>  };
>  
>  #if defined(_RTW_MP_IOCTL_C_)
> -static int oid_null_function(struct oid_par_priv *poid_par_priv) {
> +static int oid_null_function(struct oid_par_priv *poid_par_priv)
> +{
>   return NDIS_STATUS_SUCCESS;
>  }
>  #endif

Someone else sent this same patch right before you did, sorry.

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: greybus: Match alignment with open parenthesis.

2017-07-27 Thread Greg KH
On Mon, Jul 24, 2017 at 10:08:37AM +0300, Dan Carpenter wrote:
> I don't understand why greybus has to be special instead of the same as
> everything else.  Who cares about this stuff really?  Just do whatever
> is easiest and most common.

It's not special, and --strict should apply here as long as it is in
staging.  So I'll apply these types of things to prevent people from
feeling like they wasted their time fixing something up and getting it
rejected for no good reason.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Greg KH
On Thu, Jul 27, 2017 at 04:35:32PM +0300, Dan Carpenter wrote:
> On Thu, Jul 27, 2017 at 08:23:41AM -0500, Deb McLemore wrote:
> > Hi Dan,
> > 
> > Understand the readability issue, but this patch seems readable.
> > 
> 
> I would have probably merged the patch, but whatever...  Ignoring long
> lines in .h files is within normal bounds of "being special" for
> maintainers.

I merged it :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: greybus: Match alignment with open parenthesis.

2017-07-27 Thread Greg KH
On Sun, Jul 23, 2017 at 02:09:57PM +0530, Shreeya Patel wrote:
> Alignment should match with open parenthesis.
> This fixes the coding style issue.
> 
> Signed-off-by: Shreeya Patel 
> ---
>  drivers/staging/greybus/tools/loopback_test.c | 35 
> ---
>  1 file changed, 16 insertions(+), 19 deletions(-)

Does not apply cleanly to my tree, can you please rebase it and resend
if you want to have this applied?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Viresh Kumar
On 27-07-17, 08:37, Deb McLemore wrote:
> Hi Dan, thanks.
> 
> I'll look for another subsystem to help improve the quality and standards.

Please don't do *top-posting*.

> On 07/27/2017 08:35 AM, Dan Carpenter wrote:
> > On Thu, Jul 27, 2017 at 08:23:41AM -0500, Deb McLemore wrote:
> >> Hi Dan,
> >>
> >> Understand the readability issue, but this patch seems readable.
> >>
> > 
> > I would have probably merged the patch, but whatever...  Ignoring long
> > lines in .h files is within normal bounds of "being special" for
> > maintainers.

Yeah, I am not saying that this patch is completely wrong and I Nack
it, but that it was left like this intentionally. If Greg want's he
can apply that patch, I wouldn't mind. Its up to him really.

-- 
viresh
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: unisys: visorchipset: constify attribute_group structure

2017-07-27 Thread Greg KH
On Wed, Jul 26, 2017 at 09:51:32PM -0400, Amitoj Kaur Chawla wrote:
> Functions working with attribute_groups provided by 
> work with const attribute_group. These attribute_group structures do not
> change at runtime so mark them as const.
> 
> File size before:
>  text  data bss dec hex filename
>  24124 6216 448   307887844
> drivers/staging/unisys/visorbus/visorchipset.o
> 
> File size after:
>  text data bss dec hex filename
>  242206120 448   307887844
> drivers/staging/unisys/visorbus/visorchipset.o
> 
> This change was made with the help of Coccinelle.
> 
> Signed-off-by: Amitoj Kaur Chawla 
> ---
>  drivers/staging/unisys/visorbus/visorchipset.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
> b/drivers/staging/unisys/visorbus/visorchipset.c
> index 2215056..798a92e 100644
> --- a/drivers/staging/unisys/visorbus/visorchipset.c
> +++ b/drivers/staging/unisys/visorbus/visorchipset.c
> @@ -1146,7 +1146,7 @@ static struct attribute 
> *visorchipset_parahotplug_attrs[] = {
>   NULL
>  };
>  
> -static struct attribute_group visorchipset_parahotplug_group = {
> +static const struct attribute_group visorchipset_parahotplug_group = {
>   .name = "parahotplug",
>   .attrs = visorchipset_parahotplug_attrs
>  };

Someone else sent this change right before you did :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: unisys: visorbus_main: constify attribute_group structures

2017-07-27 Thread Greg KH
On Tue, Jul 25, 2017 at 06:45:52PM -0400, Amitoj Kaur Chawla wrote:
> Functions working with attribute_groups provided by 
> work with const attribute_group. These attribute_group structures do not
> change at runtime so mark them as const.
> 
> File size before:
>  text data bss dec hex filename
>  142167304 832   223525750
> drivers/staging/unisys/visorbus/visorbus_main.o
> 
> File size after:
>  text data bss dec hex filename
>  144087112 832   223525750
> drivers/staging/unisys/visorbus/visorbus_main.o
> 
> This change was made with the help of Coccinelle.
> 
> Signed-off-by: Amitoj Kaur Chawla 
> ---
>  drivers/staging/unisys/visorbus/visorbus_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
> b/drivers/staging/unisys/visorbus/visorbus_main.c
> index 1c785dd..bba10dc 100644
> --- a/drivers/staging/unisys/visorbus/visorbus_main.c
> +++ b/drivers/staging/unisys/visorbus/visorbus_main.c
> @@ -249,7 +249,7 @@ static struct attribute *channel_attrs[] = {
>   NULL
>  };
>  
> -static struct attribute_group channel_attr_grp = {
> +static const struct attribute_group channel_attr_grp = {
>   .name = "channel",
>   .attrs = channel_attrs,
>  };
> @@ -340,7 +340,7 @@ static struct attribute *dev_attrs[] = {
>   NULL
>  };
>  
> -static struct attribute_group dev_attr_grp = {
> +static const struct attribute_group dev_attr_grp = {
>   .attrs = dev_attrs,
>  };
>  

Does not apply to my tree :(

sorry,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: ccree: Convert to devm_ioremap_resource for map, unmap

2017-07-27 Thread Suniel Mahesh
On Friday 28 July 2017 01:18 AM, Dan Carpenter wrote:
> On Thu, Jul 27, 2017 at 05:27:33PM +0300, Gilad Ben-Yossef wrote:
>> +new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev,
>> + req_mem_cc_regs);
>> +if (IS_ERR(new_drvdata->cc_base)) {
>> +rc = PTR_ERR(new_drvdata->cc_base);
>>  goto init_cc_res_err;
> 
> (This code was in the original and not introduced by the patch.)

Hi Dan, the above lines of code were not in the original except 
"goto init_cc_res_err;" which was doing the error handling at different
places.

This patch has added those first three lines. I was constantly checking the 
latest
linux-next and staging-testing / next git trees. 
 
> 
> Ideally, the goto name should say what the goto does.  In this case it
> does everything.  Unfortunately trying to do everything is very
> complicated so obviously the error handling is going to be full of bugs.
> 
> The first thing the error handling does is:
> 
>   ssi_aead_free(new_drvdata);
> 
> But this function assumes that if new_drvdata->aead_handle is non-NULL
> then that means we have called:
> 
>   INIT_LIST_HEAD(&aead_handle->aead_list);
> 
> That assumption is false if the aead_handle->sram_workspace_addr
> allocation fails.  It can't actually fail in the current code...  So
> that's good, I suppose.  Reviewing this code is really hard, because I
> have to jump back and forth through several functions in different
> files.
> 
> Moving on two the second error handling function:
> 
>   ssi_hash_free(new_drvdata);
> 
> This one has basically the same assumption that if ->hash_handle is
> allocated that means we called:
> 
>   INIT_LIST_HEAD(&hash_handle->hash_list);
> 
> That assumption is not true if ssi_hash_init_sram_digest_consts(drvdata);
> fails.  That function can fail in real life.  Except the the error
> handling in ssi_hash_alloc() sets ->hash_handle to NULL.  So the bug is
> just a leak and not a crashing bug.
> 
> I've reviewed the first two lines of the error handling just to give a
> feel for how complicated "do everything" style error handling is to
> review.
> 
> The better way to do error handling is:
> 1) Only free things which have been allocated.
> 2) The unwind code should mirror the wind up code.
> 3) Every allocation function should have a free function.
> 4) Label names should tell you what the goto does.
> 5) Use direct returns and literals where possible.
> 6) Generally it's better to keep the error path and the success path
>separate.
> 7) Do error handling as opposed to success handling.
> 
>   one = alloc();
>   if (!one)
>   return -ENOMEM;
>   if (foo) {
>   two = alloc();
>   if (!two) {
>   ret = -ENOMEM;
>   goto free_one;
>   }
>   }
>   three = alloc();
>   if (!three) {
>   ret = -ENOMEM;
>   goto free_two;
>   }
>   ...
> 
>   return 0;
> 
> free_two:
>   if (foo)
>   free(two);
> free_one:
>   free(one);
> 
>   return ret;
> 
> This style of error handling is easier to review.  You only need to
> remember the most recent thing that you have allocated.  You can tell
> from the goto that it frees it so you don't have to scroll to the
> bottom of the function or jump to a different file.

I understand, its make sense, may be we should come up with something 
better and simpler.

Thanks
Suniel

> 
> regards,
> dan carpenter
> 
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v9 10/10] tracing/hyper-v: trace hyperv_mmu_flush_tlb_others()

2017-07-27 Thread Steven Rostedt
On Fri, 14 Jul 2017 14:44:42 +0200
Vitaly Kuznetsov  wrote:

> Add Hyper-V tracing subsystem and trace hyperv_mmu_flush_tlb_others().
> Tracing is done the same way we do xen_mmu_flush_tlb_others().
> 
> Signed-off-by: Vitaly Kuznetsov 
> Reviewed-by: Andy Shevchenko 
> Reviewed-by: Stephen Hemminger 

Reviewed-by: Steven Rostedt (VMware) 

(comment below)

> ---
>  MAINTAINERS |  1 +
>  arch/x86/hyperv/mmu.c   |  7 +++
>  arch/x86/include/asm/trace/hyperv.h | 40 
> +
>  3 files changed, 48 insertions(+)
>  create mode 100644 arch/x86/include/asm/trace/hyperv.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d8eab9322ba2..4a491f3b8cfd 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6276,6 +6276,7 @@ M:  Stephen Hemminger 
>  L:   de...@linuxdriverproject.org
>  S:   Maintained
>  F:   arch/x86/include/asm/mshyperv.h
> +F:   arch/x86/include/asm/trace/hyperv.h
>  F:   arch/x86/include/uapi/asm/hyperv.h
>  F:   arch/x86/kernel/cpu/mshyperv.c
>  F:   arch/x86/hyperv
> diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
> index 6fb84c4c3ee7..41bff87fb055 100644
> --- a/arch/x86/hyperv/mmu.c
> +++ b/arch/x86/hyperv/mmu.c
> @@ -8,6 +8,9 @@
>  #include 
>  #include 
>  
> +#define CREATE_TRACE_POINTS
> +#include 
> +
>  /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
>  struct hv_flush_pcpu {
>   u64 address_space;
> @@ -101,6 +104,8 @@ static void hyperv_flush_tlb_others(const struct cpumask 
> *cpus,
>   u64 status = U64_MAX;
>   unsigned long flags;
>  
> + trace_hyperv_mmu_flush_tlb_others(cpus, info);
> +
>   if (!pcpu_flush || !hv_hypercall_pg)
>   goto do_native;
>  
> @@ -170,6 +175,8 @@ static void hyperv_flush_tlb_others_ex(const struct 
> cpumask *cpus,
>   u64 status = U64_MAX;
>   unsigned long flags;
>  
> + trace_hyperv_mmu_flush_tlb_others(cpus, info);
> +
>   if (!pcpu_flush_ex || !hv_hypercall_pg)
>   goto do_native;
>  
> diff --git a/arch/x86/include/asm/trace/hyperv.h 
> b/arch/x86/include/asm/trace/hyperv.h
> new file mode 100644
> index ..4253bca99989
> --- /dev/null
> +++ b/arch/x86/include/asm/trace/hyperv.h
> @@ -0,0 +1,40 @@
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM hyperv
> +
> +#if !defined(_TRACE_HYPERV_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_HYPERV_H
> +
> +#include 
> +
> +#if IS_ENABLED(CONFIG_HYPERV)
> +
> +TRACE_EVENT(hyperv_mmu_flush_tlb_others,
> + TP_PROTO(const struct cpumask *cpus,
> +  const struct flush_tlb_info *info),
> + TP_ARGS(cpus, info),
> + TP_STRUCT__entry(
> + __field(unsigned int, ncpus)
> + __field(struct mm_struct *, mm)
> + __field(unsigned long, addr)
> + __field(unsigned long, end)
> + ),
> + TP_fast_assign(__entry->ncpus = cpumask_weight(cpus);
> +__entry->mm = info->mm;
> +__entry->addr = info->start;
> +__entry->end = info->end;
> + ),
> + TP_printk("ncpus %d mm %p addr %lx, end %lx",
> +   __entry->ncpus, __entry->mm,
> +   __entry->addr, __entry->end)
> + );
> +
> +#endif /* CONFIG_HYPERV */
> +
> +#undef TRACE_INCLUDE_PATH
> +#define TRACE_INCLUDE_PATH asm/trace/

Sometimes adding the include path in the make file may be easier. But
this is fine too.

-- Steve

> +#undef TRACE_INCLUDE_FILE
> +#define TRACE_INCLUDE_FILE hyperv
> +#endif /* _TRACE_HYPERV_H */
> +
> +/* This part must be outside protection */
> +#include 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: fix spelling mistake: "Iinitialization" -> "initialization"

2017-07-27 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in netdev_err message

Signed-off-by: Colin Ian King 
---
 drivers/staging/wilc1000/linux_wlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 1266dcccad30..119f3459b5bb 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -813,7 +813,7 @@ int wilc1000_wlan_init(struct net_device *dev, struct 
wilc_vif *vif)
wilc_wlan_cleanup(dev);
 _fail_locks_:
wlan_deinit_locks(dev);
-   netdev_err(dev, "WLAN Iinitialization FAILED\n");
+   netdev_err(dev, "WLAN initialization FAILED\n");
} else {
netdev_dbg(dev, "wilc1000 already initialized\n");
}
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: ccree: Convert to devm_ioremap_resource for map, unmap

2017-07-27 Thread Dan Carpenter
On Thu, Jul 27, 2017 at 05:27:33PM +0300, Gilad Ben-Yossef wrote:
> + new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev,
> +  req_mem_cc_regs);
> + if (IS_ERR(new_drvdata->cc_base)) {
> + rc = PTR_ERR(new_drvdata->cc_base);
>   goto init_cc_res_err;

(This code was in the original and not introduced by the patch.)

Ideally, the goto name should say what the goto does.  In this case it
does everything.  Unfortunately trying to do everything is very
complicated so obviously the error handling is going to be full of bugs.

The first thing the error handling does is:

ssi_aead_free(new_drvdata);

But this function assumes that if new_drvdata->aead_handle is non-NULL
then that means we have called:

INIT_LIST_HEAD(&aead_handle->aead_list);

That assumption is false if the aead_handle->sram_workspace_addr
allocation fails.  It can't actually fail in the current code...  So
that's good, I suppose.  Reviewing this code is really hard, because I
have to jump back and forth through several functions in different
files.

Moving on two the second error handling function:

ssi_hash_free(new_drvdata);

This one has basically the same assumption that if ->hash_handle is
allocated that means we called:

INIT_LIST_HEAD(&hash_handle->hash_list);

That assumption is not true if ssi_hash_init_sram_digest_consts(drvdata);
fails.  That function can fail in real life.  Except the the error
handling in ssi_hash_alloc() sets ->hash_handle to NULL.  So the bug is
just a leak and not a crashing bug.

I've reviewed the first two lines of the error handling just to give a
feel for how complicated "do everything" style error handling is to
review.

The better way to do error handling is:
1) Only free things which have been allocated.
2) The unwind code should mirror the wind up code.
3) Every allocation function should have a free function.
4) Label names should tell you what the goto does.
5) Use direct returns and literals where possible.
6) Generally it's better to keep the error path and the success path
   separate.
7) Do error handling as opposed to success handling.

one = alloc();
if (!one)
return -ENOMEM;
if (foo) {
two = alloc();
if (!two) {
ret = -ENOMEM;
goto free_one;
}
}
three = alloc();
if (!three) {
ret = -ENOMEM;
goto free_two;
}
...

return 0;

free_two:
if (foo)
free(two);
free_one:
free(one);

return ret;

This style of error handling is easier to review.  You only need to
remember the most recent thing that you have allocated.  You can tell
from the goto that it frees it so you don't have to scroll to the
bottom of the function or jump to a different file.

regards,
dan carpenter


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 18/20] staging: lustre: llite: Remove filtering of seclabel xattr

2017-07-27 Thread James Simmons

> From: Robin Humble 
> 
> The security.capability xattr is used to implement File
> Capabilities in recent Linux versions. Capabilities are a
> fine grained approach to granting executables elevated
> privileges. eg. /bin/ping can have capabilities
> cap_net_admin, cap_net_raw+ep instead of being setuid root.
> 
> This xattr has long been filtered out by llite, initially for
> stability reasons (b15587), and later over performance
> concerns as this xattr is read for every file with eg.
> 'ls --color'. Since LU-2869 xattr's are cached on clients,
> alleviating most performance concerns.
> 
> Removing llite's filtering of the security.capability xattr
> enables using Lustre as a root filesystem, which is used on
> some large clusters.

The commit message for this patch is incorrect. Some how it got
mixed up with another patch which I missed in this push. Please
drop this patch and I will resent the correct patches later.
 
> Signed-off-by: Robin Humble 
> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9562
> Reviewed-on: https://review.whamcloud.com/27292
> Reviewed-by: John L. Hammond 
> Reviewed-by: Sebastien Buisson 
> Reviewed-by: Oleg Drokin 
> Signed-off-by: James Simmons 
> ---
>  drivers/staging/lustre/lustre/llite/file.c | 58 
> ++
>  .../staging/lustre/lustre/llite/llite_internal.h   |  4 ++
>  drivers/staging/lustre/lustre/llite/namei.c|  6 +++
>  3 files changed, 68 insertions(+)
> 
> diff --git a/drivers/staging/lustre/lustre/llite/file.c 
> b/drivers/staging/lustre/lustre/llite/file.c
> index 215479a..a324580 100644
> --- a/drivers/staging/lustre/lustre/llite/file.c
> +++ b/drivers/staging/lustre/lustre/llite/file.c
> @@ -3040,6 +3040,61 @@ struct posix_acl *ll_get_acl(struct inode *inode, int 
> type)
>   return acl;
>  }
>  
> +#ifdef CONFIG_FS_POSIX_ACL
> +int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> +{
> + const char *name = NULL;
> + char *value = NULL;
> + size_t size = 0;
> + int rc = 0;
> +
> + switch (type) {
> + case ACL_TYPE_ACCESS:
> + if (acl) {
> + rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
> + if (rc)
> + goto out;
> + }
> + name = XATTR_NAME_POSIX_ACL_ACCESS;
> + break;
> + case ACL_TYPE_DEFAULT:
> + if (!S_ISDIR(inode->i_mode)) {
> + rc = acl ? -EACCES : 0;
> + goto out;
> + }
> + name = XATTR_NAME_POSIX_ACL_DEFAULT;
> + break;
> + default:
> + rc = -EINVAL;
> + goto out;
> + }
> +
> + if (acl) {
> + size = posix_acl_xattr_size(acl->a_count);
> + value = kmalloc(size, GFP_NOFS);
> + if (!value) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + rc = posix_acl_to_xattr(&init_user_ns, acl, value, size);
> + if (rc < 0)
> + goto out_free;
> + }
> +
> + /* dentry is only used for *.lov attributes so it's safe to be NULL */
> + rc = __vfs_setxattr(NULL, inode, name, value, size, XATTR_CREATE);
> +out_free:
> + kfree(value);
> +out:
> + if (!rc)
> + set_cached_acl(inode, type, acl);
> + else
> + forget_cached_acl(inode, type);
> + return rc;
> +}
> +#endif /* CONFIG_FS_POSIX_ACL */
> +
>  int ll_inode_permission(struct inode *inode, int mask)
>  {
>   struct ll_sb_info *sbi;
> @@ -3162,6 +3217,9 @@ int ll_inode_permission(struct inode *inode, int mask)
>   .listxattr  = ll_listxattr,
>   .fiemap = ll_fiemap,
>   .get_acl= ll_get_acl,
> +#ifdef CONFIG_FS_POSIX_ACL
> + .set_acl= ll_set_acl,
> +#endif
>  };
>  
>  /* dynamic ioctl number support routines */
> diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
> b/drivers/staging/lustre/lustre/llite/llite_internal.h
> index cd3311a..b3374bc 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
> @@ -752,6 +752,10 @@ enum ldlm_mode ll_take_md_lock(struct inode *inode, 
> __u64 bits,
>  int ll_getattr(const struct path *path, struct kstat *stat,
>  u32 request_mask, unsigned int flags);
>  struct posix_acl *ll_get_acl(struct inode *inode, int type);
> +#ifdef CONFIG_FS_POSIX_ACL
> +int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type);
> +#endif /* CONFIG_FS_POSIX_ACL */
> +
>  int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
>  const char *name, int namelen);
>  int ll_get_fid_by_name(struct inode *parent, const char *name,
> diff --git a/drivers/staging/lustre/lustre/llite/namei.c 
> b/drivers/staging/lustre/lustre/llite/namei.c
> index a208a8b..14dccbe 100644
> --- a/drivers/staging/lustre/lustre/llite/namei.c
> +++ 

[PATCH] staging: media: davinci_vpfe: use __func__ for function names

2017-07-27 Thread Diwakar Sharma
Checkpatch reported warnings for use of embedded function names.
Use __func__ instead of embedded function names.

Signed-off-by: Diwakar Sharma 
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 10 +-
 drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c |  8 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 6a3434c..a59ab6f 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -696,21 +696,21 @@ static int ipipe_get_gamma_params(struct 
vpfe_ipipe_device *ipipe, void *param)
 
if (!gamma->bypass_r && !gamma_param->table_r) {
dev_err(dev,
-   "ipipe_get_gamma_params: table ptr empty for R\n");
+   "%s: table ptr empty for R\n", __func__);
return -EINVAL;
}
memcpy(gamma_param->table_r, gamma->table_r,
   (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
 
if (!gamma->bypass_g && !gamma_param->table_g) {
-   dev_err(dev, "ipipe_get_gamma_params: table ptr empty for G\n");
+   dev_err(dev, "%s: table ptr empty for G\n", __func__);
return -EINVAL;
}
memcpy(gamma_param->table_g, gamma->table_g,
   (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
 
if (!gamma->bypass_b && !gamma_param->table_b) {
-   dev_err(dev, "ipipe_get_gamma_params: table ptr empty for B\n");
+   dev_err(dev, "%s: table ptr empty for B\n", __func__);
return -EINVAL;
}
memcpy(gamma_param->table_b, gamma->table_b,
@@ -743,7 +743,7 @@ static int ipipe_get_3d_lut_params(struct vpfe_ipipe_device 
*ipipe, void *param)
 
lut_param->en = lut->en;
if (!lut_param->table) {
-   dev_err(dev, "ipipe_get_3d_lut_params: Invalid table ptr\n");
+   dev_err(dev, "%s: Invalid table ptr\n", __func__);
return -EINVAL;
}
 
@@ -924,7 +924,7 @@ static int ipipe_get_gbce_params(struct vpfe_ipipe_device 
*ipipe, void *param)
gbce_param->en = gbce->en;
gbce_param->type = gbce->type;
if (!gbce_param->table) {
-   dev_err(dev, "ipipe_get_gbce_params: Invalid table ptr\n");
+   dev_err(dev, "%s: Invalid table ptr\n", __func__);
return -EINVAL;
}
 
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c 
b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index bffe215..16e2e7e 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -161,7 +161,7 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id)
 {
struct vpfe_device *vpfe_dev = dev_id;
 
-   v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_isr\n");
+   v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "%s\n", __func__);
vpfe_isif_buffer_isr(&vpfe_dev->vpfe_isif);
vpfe_resizer_buffer_isr(&vpfe_dev->vpfe_resizer);
return IRQ_HANDLED;
@@ -172,7 +172,7 @@ static irqreturn_t vpfe_vdint1_isr(int irq, void *dev_id)
 {
struct vpfe_device *vpfe_dev = dev_id;
 
-   v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_vdint1_isr\n");
+   v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "%s\n", __func__);
vpfe_isif_vidint1_isr(&vpfe_dev->vpfe_isif);
return IRQ_HANDLED;
 }
@@ -182,7 +182,7 @@ static irqreturn_t vpfe_imp_dma_isr(int irq, void *dev_id)
 {
struct vpfe_device *vpfe_dev = dev_id;
 
-   v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_imp_dma_isr\n");
+   v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "%s\n", __func__);
vpfe_ipipeif_ss_buffer_isr(&vpfe_dev->vpfe_ipipeif);
vpfe_resizer_dma_isr(&vpfe_dev->vpfe_resizer);
return IRQ_HANDLED;
@@ -693,7 +693,7 @@ static int vpfe_remove(struct platform_device *pdev)
 {
struct vpfe_device *vpfe_dev = platform_get_drvdata(pdev);
 
-   v4l2_info(pdev->dev.driver, "vpfe_remove\n");
+   v4l2_info(pdev->dev.driver, "%s\n", __func__);
 
kzfree(vpfe_dev->sd);
vpfe_detach_irq(vpfe_dev);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ccree: Fix unnecessary NULL check before kfree'ing it

2017-07-27 Thread Gilad Ben-Yossef
Hi,

On Thu, Jul 20, 2017 at 4:37 PM,   wrote:
> From: Suniel Mahesh 
>
> kfree(NULL) is safe and their is no need for a NULL check. Pointed out
> by checkpatch.
>
> Signed-off-by: Suniel Mahesh 
> ---
> Note:
> - Patch was compile tested and built(ARCH=arm) on next-20170719.
>   No build issues reported.

Patch applies against staging-next + latest changes and it builds and runs.

Acked-by: Gilad Ben-Yossef 

Gilad
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: Fix coding style issue for braces

2017-07-27 Thread Deb McLemore
checkpatch.pl open brace following function declaration goes on
next line so fix the brace to go properly on next line

Signed-off-by: Deb McLemore 
---
 drivers/staging/rtl8188eu/include/rtw_ioctl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h 
b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
index 0fa78ed..4c925e6 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
@@ -75,7 +75,8 @@ struct oid_par_priv {
 };
 
 #if defined(_RTW_MP_IOCTL_C_)
-static int oid_null_function(struct oid_par_priv *poid_par_priv) {
+static int oid_null_function(struct oid_par_priv *poid_par_priv)
+{
return NDIS_STATUS_SUCCESS;
 }
 #endif
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/3] staging: ccree: Replace kzalloc with devm_kzalloc

2017-07-27 Thread Gilad Ben-Yossef
On Tue, Jul 18, 2017 at 1:58 PM,   wrote:
> From: Suniel Mahesh 
>
> It is recommended to use managed function devm_kzalloc, which
> simplifies driver cleanup paths and driver code.
> This patch does the following:
> (a) replace kzalloc with devm_kzalloc.
> (b) drop kfree(), because memory allocated with devm_kzalloc() is
> automatically freed on driver detach, otherwise it leads to a double
> free.
> (c) remove unnecessary blank lines.
>
> Signed-off-by: Suniel Mahesh 
> ---
> Changes for v2:
>
> - Changes done as suggested by Greg-KH.
> - Rebased on top of next-20170718.
> ---
> Note:
>
> - Patch was tested and built(ARCH=arm) on next-20170718.
>   No build issues reported, however it was not tested on
>   real hardware.

I verified the patch set on CrytoCell HW and it's fine.

Unfortunately, my coding style fixes patch set made two of these to
fail to apply.
Following up is a rebased patch. There are no changes except resolving
conflicts.


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: ccree: Use platform_get_irq and devm_request_irq

2017-07-27 Thread Gilad Ben-Yossef
From: Suniel Mahesh 

It is recommended to use managed function devm_request_irq(),
which simplifies driver cleanup paths and driver code.
This patch does the following:
(a) replace platform_get_resource(), request_irq() and corresponding
error handling with platform_get_irq() and devm_request_irq().
(b) remove struct resource pointer(res_irq) in struct ssi_drvdata as
it seems redundant.
(c) change type of member irq in struct ssi_drvdata from unsigned int
to int, as return type of platform_get_irq is int and can be used in
error handling.
(d) remove irq_registered variable from driver probe as it seems
redundant.
(e) free_irq is not required any more, devm_request_irq() free's it
on driver detach.
(f) adjust log messages accordingly and remove any blank lines.

Signed-off-by: Suniel Mahesh 
Acked-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 30 +-
 drivers/staging/ccree/ssi_driver.h |  3 +--
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 603eb03..c18e7e3 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -222,7 +222,6 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
 {
struct resource *req_mem_cc_regs = NULL;
void __iomem *cc_base = NULL;
-   bool irq_registered = false;
struct ssi_drvdata *new_drvdata;
struct device *dev = &plat_dev->dev;
struct device_node *np = dev->of_node;
@@ -262,26 +261,22 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
  &req_mem_cc_regs->start, new_drvdata->cc_base);
cc_base = new_drvdata->cc_base;
/* Then IRQ */
-   new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 
0);
-   if (unlikely(!new_drvdata->res_irq)) {
+   new_drvdata->irq = platform_get_irq(plat_dev, 0);
+   if (new_drvdata->irq < 0) {
SSI_LOG_ERR("Failed getting IRQ resource\n");
-   rc = -ENODEV;
+   rc = new_drvdata->irq;
goto init_cc_res_err;
}
-   rc = request_irq(new_drvdata->res_irq->start, cc_isr,
-IRQF_SHARED, "arm_cc7x", new_drvdata);
-   if (unlikely(rc != 0)) {
-   SSI_LOG_ERR("Could not register to interrupt %llu\n",
-   (unsigned long long)new_drvdata->res_irq->start);
+   rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr,
+ IRQF_SHARED, "arm_cc7x", new_drvdata);
+   if (rc) {
+   SSI_LOG_ERR("Could not register to interrupt %d\n",
+   new_drvdata->irq);
goto init_cc_res_err;
}
init_completion(&new_drvdata->icache_setup_completion);
 
-   irq_registered = true;
-   SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n",
- new_drvdata->res_irq->name,
- (unsigned long long)new_drvdata->res_irq->start);
-
+   SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq);
new_drvdata->plat_dev = plat_dev;
 
rc = cc_clk_on(new_drvdata);
@@ -410,10 +405,6 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
 #ifdef ENABLE_CC_SYSFS
ssi_sysfs_fini();
 #endif
-   if (irq_registered) {
-   free_irq(new_drvdata->res_irq->start, new_drvdata);
-   new_drvdata->res_irq = NULL;
-   }
dev_set_drvdata(&plat_dev->dev, NULL);
}
return rc;
@@ -443,11 +434,8 @@ static void cleanup_cc_resources(struct platform_device 
*plat_dev)
 #ifdef ENABLE_CC_SYSFS
ssi_sysfs_fini();
 #endif
-
fini_cc_regs(drvdata);
cc_clk_off(drvdata);
-   free_irq(drvdata->res_irq->start, drvdata);
-   drvdata->res_irq = NULL;
dev_set_drvdata(&plat_dev->dev, NULL);
 }
 
diff --git a/drivers/staging/ccree/ssi_driver.h 
b/drivers/staging/ccree/ssi_driver.h
index 518c0bf..88ef370 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -128,9 +128,8 @@ struct ssi_crypto_req {
  * @fw_ver:SeP loaded firmware version
  */
 struct ssi_drvdata {
-   struct resource *res_irq;
void __iomem *cc_base;
-   unsigned int irq;
+   int irq;
u32 irq_mask;
u32 fw_ver;
/* Calibration time of start/stop
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: ccree: Convert to devm_ioremap_resource for map, unmap

2017-07-27 Thread Gilad Ben-Yossef
From: Suniel Mahesh 

It is recommended to use managed function devm_ioremap_resource(),
which simplifies driver cleanup paths and driver code.
This patch does the following:
(a) replace request_mem_region(), ioremap() and corresponding error
handling with devm_ioremap_resource().
(b) remove struct resource pointer(res_mem) in struct ssi_drvdata as it
seems redundant, use struct resource pointer which is defined locally and
adjust return value of platform_get_resource() accordingly.
(c) release_mem_region() and iounmap() are dropped, since devm_ioremap_
resource() releases and unmaps mem region on driver detach.
(d) adjust log messages accordingly and remove any blank lines.

Signed-off-by: Suniel Mahesh 
[gby: rebase on top of latest coding style fixes changes]
Acked-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 60 ++
 drivers/staging/ccree/ssi_driver.h |  1 -
 2 files changed, 15 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 97dfc2c..603eb03 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -246,35 +246,21 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
dev_set_drvdata(&plat_dev->dev, new_drvdata);
/* Get device resources */
/* First CC registers space */
-   new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 
0);
-   if (unlikely(!new_drvdata->res_mem)) {
-   SSI_LOG_ERR("Failed getting IO memory resource\n");
-   rc = -ENODEV;
-   goto init_cc_res_err;
-   }
-   SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n",
- new_drvdata->res_mem->name,
- new_drvdata->res_mem->start,
- new_drvdata->res_mem->end);
+   req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
/* Map registers space */
-   req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, 
resource_size(new_drvdata->res_mem), "arm_cc7x_regs");
-   if (unlikely(!req_mem_cc_regs)) {
-   SSI_LOG_ERR("Couldn't allocate registers memory region at 
0x%08X\n",
-   (unsigned int)new_drvdata->res_mem->start);
-   rc = -EBUSY;
-   goto init_cc_res_err;
-   }
-   cc_base = ioremap(new_drvdata->res_mem->start, 
resource_size(new_drvdata->res_mem));
-   if (unlikely(!cc_base)) {
-   SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n",
-   (unsigned int)new_drvdata->res_mem->start,
-   (unsigned int)resource_size(new_drvdata->res_mem));
-   rc = -ENOMEM;
+   new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev,
+req_mem_cc_regs);
+   if (IS_ERR(new_drvdata->cc_base)) {
+   rc = PTR_ERR(new_drvdata->cc_base);
goto init_cc_res_err;
}
-   SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", 
&new_drvdata->res_mem->start, cc_base);
-   new_drvdata->cc_base = cc_base;
-
+   SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n",
+ req_mem_cc_regs->name,
+ req_mem_cc_regs->start,
+ req_mem_cc_regs->end);
+   SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n",
+ &req_mem_cc_regs->start, new_drvdata->cc_base);
+   cc_base = new_drvdata->cc_base;
/* Then IRQ */
new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 
0);
if (unlikely(!new_drvdata->res_irq)) {
@@ -424,17 +410,9 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
 #ifdef ENABLE_CC_SYSFS
ssi_sysfs_fini();
 #endif
-
-   if (req_mem_cc_regs) {
-   if (irq_registered) {
-   free_irq(new_drvdata->res_irq->start, 
new_drvdata);
-   new_drvdata->res_irq = NULL;
-   iounmap(cc_base);
-   new_drvdata->cc_base = NULL;
-   }
-   release_mem_region(new_drvdata->res_mem->start,
-  resource_size(new_drvdata->res_mem));
-   new_drvdata->res_mem = NULL;
+   if (irq_registered) {
+   free_irq(new_drvdata->res_irq->start, new_drvdata);
+   new_drvdata->res_irq = NULL;
}
dev_set_drvdata(&plat_dev->dev, NULL);
}
@@ -470,14 +448,6 @@ static void cleanup_cc_resources(struct platform_device 
*plat_dev)
cc_clk_off(drvdata);
free_irq(drvdata->res_irq->start, drvdata);
drvdata->res_irq = NULL;
-
-   if (drvdata->cc_base) {
-   iounmap(drvdata->c

[PATCH 1/3] staging: ccree: Replace kzalloc with devm_kzalloc

2017-07-27 Thread Gilad Ben-Yossef
From: Suniel Mahesh 

It is recommended to use managed function devm_kzalloc, which
simplifies driver cleanup paths and driver code.
This patch does the following:
(a) replace kzalloc with devm_kzalloc.
(b) drop kfree(), because memory allocated with devm_kzalloc() is
automatically freed on driver detach, otherwise it leads to a double
free.
(c) remove unnecessary blank lines.

Signed-off-by: Suniel Mahesh 
[gby: rebase on top of latest coding style fixes changes]
Acked-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_driver.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index 1cae2b7..97dfc2c 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -223,13 +223,15 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
struct resource *req_mem_cc_regs = NULL;
void __iomem *cc_base = NULL;
bool irq_registered = false;
-   struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), 
GFP_KERNEL);
+   struct ssi_drvdata *new_drvdata;
struct device *dev = &plat_dev->dev;
struct device_node *np = dev->of_node;
u32 signature_val;
int rc = 0;
 
-   if (unlikely(!new_drvdata)) {
+   new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(*new_drvdata),
+  GFP_KERNEL);
+   if (!new_drvdata) {
SSI_LOG_ERR("Failed to allocate drvdata");
rc = -ENOMEM;
goto init_cc_res_err;
@@ -434,10 +436,8 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
   resource_size(new_drvdata->res_mem));
new_drvdata->res_mem = NULL;
}
-   kfree(new_drvdata);
dev_set_drvdata(&plat_dev->dev, NULL);
}
-
return rc;
 }
 
@@ -478,8 +478,6 @@ static void cleanup_cc_resources(struct platform_device 
*plat_dev)
drvdata->cc_base = NULL;
drvdata->res_mem = NULL;
}
-
-   kfree(drvdata);
dev_set_drvdata(&plat_dev->dev, NULL);
 }
 
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: greybus: light: Don't leak memory for no gain

2017-07-27 Thread Rui Miguel Silva
Hi,
On Wed, Jul 26, 2017 at 08:32:08PM +0200, Pavel Machek wrote:
> Hi!
> 
> > On Tue, Jul 25, 2017 at 02:30:31PM +0200, Johan Hovold wrote:
> > > [ +CC: Rui and Greg ]
> > 
> > Thanks Johan. I only got this because of you.
> 
> > > > return ret;
> > > >  }
> > > 
> > > And while it's fine to take this through linux-media, it would still be
> > > good to keep the maintainers on CC.
> > 
> > Sakari, if you could resend the all series to the right lists and
> > maintainers for proper review that would be great.
> > 
> > I did not get 0/2 and 2/2 patches.
> 
> 0/2 and 2/2 were unrelated to the memory leak, IIRC. Let me google it
> for you...
> 
> https://www.mail-archive.com/linux-media@vger.kernel.org/msg115840.html
> 
> This is memory leak and the driver is in staging. Acked-by

Yeah, I will not Ack a patch that never hit my inbox, sorry.

>or fixing > it yourself would be appropriate response, asking
> for resending of the series... not quite so.

Sure, if Sakari do not send a new version already taking in
account Johan comments, which I agree. I will fix it myself when
possible.

---
Cheers,
Rui
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/37] binder: use group leader instead of open thread

2017-07-27 Thread Amit Pundir
On 27 July 2017 at 18:53, Greg Kroah-Hartman  wrote:
> On Thu, Jul 27, 2017 at 02:38:30PM +0530, Amit Pundir wrote:
>> Hi,
>>
>> On 25 July 2017 at 14:43, Martijn Coenen  wrote:
>> > Hi John,
>> >
>> > On Mon, Jul 24, 2017 at 11:07 PM, John Stultz  
>> > wrote:
>> >>
>> >> 12-31 16:00:36.632  2518  2584 E hw-ProcessState: Using /dev/hwbinder
>> >> failed: unable to mmap transaction memory.
>> >
>> > This doesn't look right. Is there anything in the kernel log?
>>
>> There is a slight difference in this patch and the one that got pushed
>> in android-4.9[1]. I cherry-picked those changes and got BT/WiFi
>> working again on Hikey with mainline tracking (4.13-rc2) tree.
>>
>> Regards,
>> Amit Pundir
>> [1] 
>> https://android.googlesource.com/kernel/common/+/872c26eb0776ef160447d8703779e2bce0b7230a%5E%21/#F0
>
> And what is that difference?

These couple of lines of change:

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f7665c31feca..d7291a5a13e1 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3362,7 +3362,7 @@ static int binder_mmap(struct file *filp, struct
vm_area_struct *vma)
const char *failure_string;
struct binder_buffer *buffer;

-   if (proc->tsk != current)
+   if (proc->tsk != current->group_leader)
return -EINVAL;

if ((vma->vm_end - vma->vm_start) > SZ_4M)
@@ -3466,6 +3466,7 @@ static int binder_open(struct inode *nodp,
struct file *filp)
return -ENOMEM;
get_task_struct(current->group_leader);
proc->tsk = current->group_leader;
+   proc->vma_vm_mm = current->group_leader->mm;
INIT_LIST_HEAD(&proc->todo);
init_waitqueue_head(&proc->wait);
proc->default_priority = task_nice(current);

John reported hw_binder mmap failure in his logcat. So I'm assuming
that the check in binder_mmap is where the binder failed and returned.

Regards,
Amit Pundir
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Deb McLemore
Hi Dan, thanks.

I'll look for another subsystem to help improve the quality and standards.

On 07/27/2017 08:35 AM, Dan Carpenter wrote:
> On Thu, Jul 27, 2017 at 08:23:41AM -0500, Deb McLemore wrote:
>> Hi Dan,
>>
>> Understand the readability issue, but this patch seems readable.
>>
> 
> I would have probably merged the patch, but whatever...  Ignoring long
> lines in .h files is within normal bounds of "being special" for
> maintainers.
> 
> regards,
> dan carpenter
> 
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Dan Carpenter
On Thu, Jul 27, 2017 at 08:23:41AM -0500, Deb McLemore wrote:
> Hi Dan,
> 
> Understand the readability issue, but this patch seems readable.
> 

I would have probably merged the patch, but whatever...  Ignoring long
lines in .h files is within normal bounds of "being special" for
maintainers.

regards,
dan carpenter


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Deb McLemore
Hi Dan,

Understand the readability issue, but this patch seems readable.

On 07/27/2017 08:16 AM, Dan Carpenter wrote:
> On Thu, Jul 27, 2017 at 08:10:35AM -0500, Deb McLemore wrote:
>> Hi Viresh,
>>
>> So does greybus not follow the coding style from checkpatch.pl ?
>>
> 
> Sometimes people go over the 80 character limit if we think it's more
> readable.
> 
> regards,
> dan carpenter
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/37] binder: use group leader instead of open thread

2017-07-27 Thread Greg Kroah-Hartman
On Thu, Jul 27, 2017 at 02:38:30PM +0530, Amit Pundir wrote:
> Hi,
> 
> On 25 July 2017 at 14:43, Martijn Coenen  wrote:
> > Hi John,
> >
> > On Mon, Jul 24, 2017 at 11:07 PM, John Stultz  
> > wrote:
> >>
> >> 12-31 16:00:36.632  2518  2584 E hw-ProcessState: Using /dev/hwbinder
> >> failed: unable to mmap transaction memory.
> >
> > This doesn't look right. Is there anything in the kernel log?
> 
> There is a slight difference in this patch and the one that got pushed
> in android-4.9[1]. I cherry-picked those changes and got BT/WiFi
> working again on Hikey with mainline tracking (4.13-rc2) tree.
> 
> Regards,
> Amit Pundir
> [1] 
> https://android.googlesource.com/kernel/common/+/872c26eb0776ef160447d8703779e2bce0b7230a%5E%21/#F0

And what is that difference?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Dan Carpenter
On Thu, Jul 27, 2017 at 08:10:35AM -0500, Deb McLemore wrote:
> Hi Viresh,
> 
> So does greybus not follow the coding style from checkpatch.pl ?
> 

Sometimes people go over the 80 character limit if we think it's more
readable.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: Fix coding style issue for column width

2017-07-27 Thread Deb McLemore
Hi Viresh,

So does greybus not follow the coding style from checkpatch.pl ?

On 07/26/2017 10:32 PM, Viresh Kumar wrote:
> On 26-07-17, 17:13, Deb McLemore wrote:
>> checkpatch.pl line over 80 characters so fix the formatting
>> for coding style compliance.
>>
>> Signed-off-by: Deb McLemore 
>> ---
>>  drivers/staging/greybus/spilib.h | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/greybus/spilib.h 
>> b/drivers/staging/greybus/spilib.h
>> index 566d0dd..cb60925 100644
>> --- a/drivers/staging/greybus/spilib.h
>> +++ b/drivers/staging/greybus/spilib.h
>> @@ -18,7 +18,8 @@ struct spilib_ops {
>>  void (*unprepare_transfer_hardware)(struct device *dev);
>>  };
>>  
>> -int gb_spilib_master_init(struct gb_connection *connection, struct device 
>> *dev, struct spilib_ops *ops);
>> +int gb_spilib_master_init(struct gb_connection *connection,
>> +  struct device *dev, struct spilib_ops *ops);
> 
> It was intentionally written so and you will find tons of examples of
> such declarations in the .h files specially.
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: ccree: remove func name from log messages

2017-07-27 Thread Gilad Ben-Yossef
The SSI_LOG macros already add __func__ to log messages, so remove
log message that add them a second time in the log message itself.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_aead.c   |  4 ++--
 drivers/staging/ccree/ssi_cipher.c | 14 +++---
 drivers/staging/ccree/ssi_driver.c |  2 +-
 drivers/staging/ccree/ssi_hash.c   |  2 +-
 drivers/staging/ccree/ssi_pm.c |  4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index c6edef0..aa94839 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -2269,7 +2269,7 @@ static int ssi_gcm_setauthsize(struct crypto_aead 
*authenc,
 static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc,
   unsigned int authsize)
 {
-   SSI_LOG_DEBUG("ssi_rfc4106_gcm_setauthsize()  authsize %d\n", authsize);
+   SSI_LOG_DEBUG("authsize %d\n", authsize);
 
switch (authsize) {
case 8:
@@ -2286,7 +2286,7 @@ static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead 
*authenc,
 static int ssi_rfc4543_gcm_setauthsize(struct crypto_aead *authenc,
   unsigned int authsize)
 {
-   SSI_LOG_DEBUG("ssi_rfc4543_gcm_setauthsize()  authsize %d\n", authsize);
+   SSI_LOG_DEBUG("authsize %d\n", authsize);
 
if (authsize != 16)
return -EINVAL;
diff --git a/drivers/staging/ccree/ssi_cipher.c 
b/drivers/staging/ccree/ssi_cipher.c
index 4ee2a12..61976b5 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -304,7 +304,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
  ctx_p, crypto_tfm_alg_name(tfm), keylen);
dump_byte_array("key", (u8 *)key, keylen);
 
-   SSI_LOG_DEBUG("ssi_blkcipher_setkey: after FIPS check");
+   SSI_LOG_DEBUG("after FIPS check");
 
/* STAT_PHASE_0: Init and sanity checks */
 
@@ -350,7 +350,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
}
 
ctx_p->keylen = keylen;
-   SSI_LOG_DEBUG("ssi_blkcipher_setkey: ssi_is_hw_key ret 0");
+   SSI_LOG_DEBUG("ssi_is_hw_key ret 0");
 
return 0;
}
@@ -360,19 +360,19 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
if (unlikely(!des_ekey(tmp, key)) &&
(crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_WEAK_KEY)) {
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
-   SSI_LOG_DEBUG("ssi_blkcipher_setkey:  weak DES key");
+   SSI_LOG_DEBUG("weak DES key");
return -EINVAL;
}
}
if ((ctx_p->cipher_mode == DRV_CIPHER_XTS) &&
xts_check_key(tfm, key, keylen) != 0) {
-   SSI_LOG_DEBUG("ssi_blkcipher_setkey: weak XTS key");
+   SSI_LOG_DEBUG("weak XTS key");
return -EINVAL;
}
if ((ctx_p->flow_mode == S_DIN_to_DES) &&
(keylen == DES3_EDE_KEY_SIZE) &&
ssi_verify_3des_keys(key, keylen) != 0) {
-   SSI_LOG_DEBUG("ssi_blkcipher_setkey: weak 3DES key");
+   SSI_LOG_DEBUG("weak 3DES key");
return -EINVAL;
}
 
@@ -387,7 +387,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
if (ctx_p->key_round_number < CC_MULTI2_MIN_NUM_ROUNDS ||
ctx_p->key_round_number > CC_MULTI2_MAX_NUM_ROUNDS) {
crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
-   SSI_LOG_DEBUG("ssi_blkcipher_setkey: SSI_CC_HAS_MULTI2 
einval");
+   SSI_LOG_DEBUG("SSI_CC_HAS_MULTI2 einval");
return -EINVAL;
 #endif /*SSI_CC_HAS_MULTI2*/
} else {
@@ -414,7 +414,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm,
   max_key_buf_size, DMA_TO_DEVICE);
ctx_p->keylen = keylen;
 
-SSI_LOG_DEBUG("ssi_blkcipher_setkey: return safely");
+SSI_LOG_DEBUG("return safely");
return 0;
 }
 
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index b26eebd..d104dbd 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -81,7 +81,7 @@ void dump_byte_array(const char *name, const u8 *the_array, 
unsigned long size)
char line_buf[80];
 
if (!the_array) {
-   SSI_LOG_ERR("cannot %s - NULL pointer\n", __func__);
+   SSI_LOG_ERR("cannot dump array - NULL pointer\n");
return;
}
 
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index eb5b78f..736dedc 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -974,7 +974,7 @@ static int ssi_hash_setkey(void *hash,
   

[PATCH 4/4] staging: ccree: kmalloc by sizeof var not type

2017-07-27 Thread Gilad Ben-Yossef
Change places where we alloc memory by sizeof type to sizeof var.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_aead.c| 4 ++--
 drivers/staging/ccree/ssi_cipher.c  | 4 ++--
 drivers/staging/ccree/ssi_driver.c  | 2 +-
 drivers/staging/ccree/ssi_hash.c| 4 ++--
 drivers/staging/ccree/ssi_ivgen.c   | 2 +-
 drivers/staging/ccree/ssi_request_mgr.c | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index aa94839..15d05af 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -2659,7 +2659,7 @@ static struct ssi_crypto_alg *ssi_aead_create_alg(struct 
ssi_alg_template *templ
struct ssi_crypto_alg *t_alg;
struct aead_alg *alg;
 
-   t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL);
+   t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
if (!t_alg) {
SSI_LOG_ERR("failed to allocate t_alg\n");
return ERR_PTR(-ENOMEM);
@@ -2714,7 +2714,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata)
int rc = -ENOMEM;
int alg;
 
-   aead_handle = kmalloc(sizeof(struct ssi_aead_handle), GFP_KERNEL);
+   aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL);
if (!aead_handle) {
rc = -ENOMEM;
goto fail0;
diff --git a/drivers/staging/ccree/ssi_cipher.c 
b/drivers/staging/ccree/ssi_cipher.c
index 61976b5..e09fe03 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -1214,7 +1214,7 @@ struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct 
ssi_alg_template *templa
struct ssi_crypto_alg *t_alg;
struct crypto_alg *alg;
 
-   t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL);
+   t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
if (!t_alg) {
SSI_LOG_ERR("failed to allocate t_alg\n");
return ERR_PTR(-ENOMEM);
@@ -1275,7 +1275,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata)
int rc = -ENOMEM;
int alg;
 
-   ablkcipher_handle = kmalloc(sizeof(struct ssi_blkcipher_handle),
+   ablkcipher_handle = kmalloc(sizeof(*ablkcipher_handle),
GFP_KERNEL);
if (!ablkcipher_handle)
return -ENOMEM;
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index d104dbd..1cae2b7 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -223,7 +223,7 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
struct resource *req_mem_cc_regs = NULL;
void __iomem *cc_base = NULL;
bool irq_registered = false;
-   struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), 
GFP_KERNEL);
+   struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), 
GFP_KERNEL);
struct device *dev = &plat_dev->dev;
struct device_node *np = dev->of_node;
u32 signature_val;
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 736dedc..713be20 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -2060,7 +2060,7 @@ ssi_hash_create_alg(struct ssi_hash_template *template, 
bool keyed)
struct crypto_alg *alg;
struct ahash_alg *halg;
 
-   t_crypto_alg = kzalloc(sizeof(struct ssi_hash_alg), GFP_KERNEL);
+   t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL);
if (!t_crypto_alg) {
SSI_LOG_ERR("failed to allocate t_alg\n");
return ERR_PTR(-ENOMEM);
@@ -2224,7 +2224,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
int rc = 0;
int alg;
 
-   hash_handle = kzalloc(sizeof(struct ssi_hash_handle), GFP_KERNEL);
+   hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL);
if (!hash_handle) {
SSI_LOG_ERR("kzalloc failed to allocate %zu B\n",
sizeof(struct ssi_hash_handle));
diff --git a/drivers/staging/ccree/ssi_ivgen.c 
b/drivers/staging/ccree/ssi_ivgen.c
index c6f400f..8d6f8ad 100644
--- a/drivers/staging/ccree/ssi_ivgen.c
+++ b/drivers/staging/ccree/ssi_ivgen.c
@@ -191,7 +191,7 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata)
int rc;
 
/* Allocate "this" context */
-   drvdata->ivgen_handle = kzalloc(sizeof(struct ssi_ivgen_ctx), 
GFP_KERNEL);
+   drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle), 
GFP_KERNEL);
if (!drvdata->ivgen_handle) {
SSI_LOG_ERR("Not enough memory to allocate IVGEN context (%zu 
B)\n",
sizeof(struct ssi_ivgen_ctx));
diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
b/drivers/staging/ccree/ssi_request_mgr.c
index 9a4bb5c..cae9904 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -

[PATCH 2/4] staging: ccree: fix split strings

2017-07-27 Thread Gilad Ben-Yossef
Fix strings in log messages being split across lines and the resulting
alignment issues when being fixed.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_aead.c|  9 ++--
 drivers/staging/ccree/ssi_buffer_mgr.c  | 86 ++---
 drivers/staging/ccree/ssi_cipher.c  | 27 +--
 drivers/staging/ccree/ssi_driver.c  |  4 +-
 drivers/staging/ccree/ssi_hash.c| 43 -
 drivers/staging/ccree/ssi_ivgen.c   |  8 +--
 drivers/staging/ccree/ssi_request_mgr.c | 13 ++---
 7 files changed, 81 insertions(+), 109 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 1a1ae50..c6edef0 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -240,9 +240,8 @@ static void ssi_aead_complete(struct device *dev, void 
*ssi_req, void __iomem *c
if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) {
if (memcmp(areq_ctx->mac_buf, areq_ctx->icv_virt_addr,
   ctx->authsize) != 0) {
-   SSI_LOG_DEBUG("Payload authentication failure, "
-   "(auth-size=%d, cipher=%d).\n",
-   ctx->authsize, ctx->cipher_mode);
+   SSI_LOG_DEBUG("Payload authentication failure, 
(auth-size=%d, cipher=%d).\n",
+ ctx->authsize, ctx->cipher_mode);
/* In case of payload authentication failure, MUST NOT
 * revealed the decrypted message --> zero its memory.
 */
@@ -455,8 +454,8 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 
*key, unsigned int keyl
if (likely(keylen != 0)) {
key_dma_addr = dma_map_single(dev, (void *)key, keylen, 
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(dev, key_dma_addr))) {
-   SSI_LOG_ERR("Mapping key va=0x%p len=%u for"
-  " DMA failed\n", key, keylen);
+   SSI_LOG_ERR("Mapping key va=0x%p len=%u for DMA 
failed\n",
+   key, keylen);
return -ENOMEM;
}
if (keylen > blocksize) {
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c 
b/drivers/staging/ccree/ssi_buffer_mgr.c
index 6f8d372..648be32 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -82,8 +82,8 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents(
 
while (nbytes != 0) {
if (sg_is_chain(sg_list)) {
-   SSI_LOG_ERR("Unexpected chained entry "
-  "in sg (entry =0x%X)\n", nents);
+   SSI_LOG_ERR("Unexpected chained entry in sg (entry 
=0x%X)\n",
+   nents);
BUG();
}
if (sg_list->length != 0) {
@@ -259,11 +259,9 @@ static int ssi_buffer_mgr_generate_mlli(
/* Set MLLI size for the bypass operation */
mlli_params->mlli_len = (total_nents * LLI_ENTRY_BYTE_SIZE);
 
-   SSI_LOG_DEBUG("MLLI params: "
-"virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n",
-  mlli_params->mlli_virt_addr,
-  mlli_params->mlli_dma_addr,
-  mlli_params->mlli_len);
+   SSI_LOG_DEBUG("MLLI params: virt_addr=%pK dma_addr=%pad 
mlli_len=0x%X\n",
+ mlli_params->mlli_virt_addr, mlli_params->mlli_dma_addr,
+ mlli_params->mlli_len);
 
 build_mlli_exit:
return rc;
@@ -276,9 +274,8 @@ static inline void ssi_buffer_mgr_add_buffer_entry(
 {
unsigned int index = sgl_data->num_of_buffers;
 
-   SSI_LOG_DEBUG("index=%u single_buff=%pad "
-"buffer_len=0x%08X is_last=%d\n",
-index, buffer_dma, buffer_len, is_last_entry);
+   SSI_LOG_DEBUG("index=%u single_buff=%pad buffer_len=0x%08X 
is_last=%d\n",
+ index, buffer_dma, buffer_len, is_last_entry);
sgl_data->nents[index] = 1;
sgl_data->entry[index].buffer_dma = buffer_dma;
sgl_data->offset[index] = 0;
@@ -359,8 +356,7 @@ static int ssi_buffer_mgr_map_scatterlist(
SSI_LOG_ERR("dma_map_sg() single buffer failed\n");
return -ENOMEM;
}
-   SSI_LOG_DEBUG("Mapped sg: dma_address=%pad "
-"page=%p addr=%pK offset=%u "
+   SSI_LOG_DEBUG("Mapped sg: dma_address=%pad page=%p addr=%pK 
offset=%u "
 "length=%u\n",
 sg_dma_address(sg),
 sg_page(sg),
@@ -419,12 +415,10 @@ ssi_aead_handle_config_buf(struct device *dev,
sg_init_one(&areq_ctx->ccm_adata_sg, config_data, AES_BLOCK_SIZE + 
areq_ctx->ccm_hdr_s

[PATCH 1/4] staging: ccree: fix parenthesis alignment

2017-07-27 Thread Gilad Ben-Yossef
Fix various remaining parenthesis alignment issues.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_aead.c| 46 +
 drivers/staging/ccree/ssi_buffer_mgr.c  | 30 ++-
 drivers/staging/ccree/ssi_cipher.c  |  2 +-
 drivers/staging/ccree/ssi_hash.c| 88 +
 drivers/staging/ccree/ssi_ivgen.c   |  2 +-
 drivers/staging/ccree/ssi_request_mgr.c |  4 +-
 6 files changed, 94 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index ea29b8a..1a1ae50 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -96,7 +96,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
 
SSI_LOG_DEBUG("Clearing context @%p for %s\n",
-   crypto_aead_ctx(tfm), crypto_tfm_alg_name(&tfm->base));
+ crypto_aead_ctx(tfm), crypto_tfm_alg_name(&tfm->base));
 
dev = &ctx->drvdata->plat_dev->dev;
/* Unmap enckey buffer */
@@ -163,7 +163,7 @@ static int ssi_aead_init(struct crypto_aead *tfm)
 
/* Allocate key buffer, cache line aligned */
ctx->enckey = dma_alloc_coherent(dev, AES_MAX_KEY_SIZE,
-   &ctx->enckey_dma_addr, GFP_KERNEL);
+&ctx->enckey_dma_addr, GFP_KERNEL);
if (!ctx->enckey) {
SSI_LOG_ERR("Failed allocating key buffer\n");
goto init_failed;
@@ -239,7 +239,7 @@ static void ssi_aead_complete(struct device *dev, void 
*ssi_req, void __iomem *c
 
if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) {
if (memcmp(areq_ctx->mac_buf, areq_ctx->icv_virt_addr,
-   ctx->authsize) != 0) {
+  ctx->authsize) != 0) {
SSI_LOG_DEBUG("Payload authentication failure, "
"(auth-size=%d, cipher=%d).\n",
ctx->authsize, ctx->cipher_mode);
@@ -378,7 +378,7 @@ static int hmac_setkey(struct cc_hw_desc *desc, struct 
ssi_aead_ctx *ctx)
 static int validate_keys_sizes(struct ssi_aead_ctx *ctx)
 {
SSI_LOG_DEBUG("enc_keylen=%u  authkeylen=%u\n",
-   ctx->enc_keylen, ctx->auth_keylen);
+ ctx->enc_keylen, ctx->auth_keylen);
 
switch (ctx->auth_mode) {
case DRV_HASH_SHA1:
@@ -402,7 +402,7 @@ static int validate_keys_sizes(struct ssi_aead_ctx *ctx)
if (unlikely(ctx->flow_mode == S_DIN_to_DES)) {
if (ctx->enc_keylen != DES3_EDE_KEY_SIZE) {
SSI_LOG_ERR("Invalid cipher(3DES) key size: %u\n",
-   ctx->enc_keylen);
+   ctx->enc_keylen);
return -EINVAL;
}
} else { /* Default assumed to be AES ciphers */
@@ -410,7 +410,7 @@ static int validate_keys_sizes(struct ssi_aead_ctx *ctx)
(ctx->enc_keylen != AES_KEYSIZE_192) &&
(ctx->enc_keylen != AES_KEYSIZE_256)) {
SSI_LOG_ERR("Invalid cipher(AES) key size: %u\n",
-   ctx->enc_keylen);
+   ctx->enc_keylen);
return -EINVAL;
}
}
@@ -553,7 +553,8 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, 
unsigned int keylen)
int seq_len = 0, rc = -EINVAL;
 
SSI_LOG_DEBUG("Setting key in context @%p for %s. key=%p keylen=%u\n",
-   ctx, crypto_tfm_alg_name(crypto_aead_tfm(tfm)), key, keylen);
+ ctx, crypto_tfm_alg_name(crypto_aead_tfm(tfm)), key,
+ keylen);
 
/* STAT_PHASE_0: Init and sanity checks */
 
@@ -684,7 +685,7 @@ static int ssi_aead_setauthsize(
 
 #if SSI_CC_HAS_AES_CCM
 static int ssi_rfc4309_ccm_setauthsize(struct crypto_aead *authenc,
- unsigned int authsize)
+  unsigned int authsize)
 {
switch (authsize) {
case 8:
@@ -699,7 +700,7 @@ static int ssi_rfc4309_ccm_setauthsize(struct crypto_aead 
*authenc,
 }
 
 static int ssi_ccm_setauthsize(struct crypto_aead *authenc,
- unsigned int authsize)
+  unsigned int authsize)
 {
switch (authsize) {
case 4:
@@ -1183,7 +1184,7 @@ static inline void ssi_aead_load_mlli_to_sram(
(req_ctx->data_buff_type == SSI_DMA_BUF_MLLI) ||
!req_ctx->is_single_pass)) {
SSI_LOG_DEBUG("Copy-to-sram: mlli_dma=%08x, mlli_size=%u\n",
-   (unsigned int)ctx->drvdata->mlli_sram_addr,
+ (unsigned int)ctx->drvdata->mlli_sram_addr,
req_ctx->mlli_params.mlli_len);
/* Copy MLLI table host-to-sram */

[PATCH 0/4] staging: ccree: coding style clean ups

2017-07-27 Thread Gilad Ben-Yossef
Misc. coding style fixes for ccree driver.

These are the missing patches that failed to apply two weeks ago,
rebased onto latest staging-next.

By the way, I still do not understand why they failed to apply,
as they applied just fine being cherry picked on top of latest
staging-next apart for fixes for later changes. I hope these will
be good.

Gilad Ben-Yossef (4):
  staging: ccree: fix parenthesis alignment
  staging: ccree: fix split strings
  staging: ccree: remove func name from log messages
  staging: ccree: kmalloc by sizeof var not type

 drivers/staging/ccree/ssi_aead.c|  63 ---
 drivers/staging/ccree/ssi_buffer_mgr.c  | 116 ---
 drivers/staging/ccree/ssi_cipher.c  |  47 +--
 drivers/staging/ccree/ssi_driver.c  |   8 +-
 drivers/staging/ccree/ssi_hash.c| 137 
 drivers/staging/ccree/ssi_ivgen.c   |  12 +--
 drivers/staging/ccree/ssi_pm.c  |   4 +-
 drivers/staging/ccree/ssi_request_mgr.c |  19 +++--
 8 files changed, 197 insertions(+), 209 deletions(-)

-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/37] binder: use group leader instead of open thread

2017-07-27 Thread Amit Pundir
Hi,

On 25 July 2017 at 14:43, Martijn Coenen  wrote:
> Hi John,
>
> On Mon, Jul 24, 2017 at 11:07 PM, John Stultz  wrote:
>>
>> 12-31 16:00:36.632  2518  2584 E hw-ProcessState: Using /dev/hwbinder
>> failed: unable to mmap transaction memory.
>
> This doesn't look right. Is there anything in the kernel log?

There is a slight difference in this patch and the one that got pushed
in android-4.9[1]. I cherry-picked those changes and got BT/WiFi
working again on Hikey with mainline tracking (4.13-rc2) tree.

Regards,
Amit Pundir
[1] 
https://android.googlesource.com/kernel/common/+/872c26eb0776ef160447d8703779e2bce0b7230a%5E%21/#F0

>
>> 12-31 16:00:36.632  2518  2566 D bt_hci  : hci_module_start_up
>> starting async portion
>> 12-31 16:00:36.632  2518  2584 E
>> android.hardware.bluetooth@1.0::BluetoothHci: getService:
>> defaultServiceManager()->getTransport returns
>> Status(EX_TRANSACTION_FAILED): '-9 Bad file descriptor: '
>> 12-31 16:00:36.633  2518  2584 F :
>> [1231/160036:FATAL:hci_layer_android.cc(109)] Check failed: btHci !=
>> nullptr.
>> 12-31 16:00:36.634  2518  2584 F libc: Fatal signal 6 (SIGABRT),
>> code -6 in tid 2584 (hci_thread)
>> ...
>> 12-31 16:00:38.027  2009  2061 E SupplicantStaIfaceHal: Exception
>> while trying to register a listener for ISupplicant service:
>> android.os.RemoteException: HwBinder Error: (-2147483648)
>> 12-31 16:00:38.027  2009  2061 E WifiMonitor: startMonitoring(wlan0) failed!
>> 12-31 16:00:38.028  2009  2061 E SupplicantStaIfaceHal: Can't call
>> setDebugParams, ISupplicant is null
>> 12-31 16:00:38.030  2009  2061 D WifiConfigStore: Reading from stores
>> completed in 2 ms.
>> 12-31 16:00:38.034  2009  2061 D WIFI: Registering NetworkFactory
>> 12-31 16:00:38.035  2009  2061 D WIFI_UT : Registering NetworkFactory
>> 12-31 16:00:38.035  2009  2065 D ConnectivityService: Got
>> NetworkFactory Messenger for WIFI
>> 12-31 16:00:38.035  2009  2065 D ConnectivityService: Got
>> NetworkFactory Messenger for WIFI_UT
>> 12-31 16:00:38.037  2009  2061 D WifiConfigStore: Reading from user
>> store completed in 2 ms.
>> 12-31 16:00:38.055  2009  2061 D WifiConfigStore: Writing to stores
>> completed in 17 ms.
>> 12-31 16:00:38.055  2009  2061 E WifiStateMachine: Failed to setup
>> control channel, restart supplicant
>> ...
>> etc.
>>
>> thanks
>> -john
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: lustre: replace simple_strtoul with kstrtoint

2017-07-27 Thread Marcin Ciupak
I did test it and not everything works as expected. I
need to reconsider that change. Please drop this patch.

Thanks,
Marcin

P.S. Sorry for late (sic!) response.

On Fri, Apr 14, 2017 at 10:16:31AM +0200, Greg Kroah-Hartman wrote:
> On Tue, Mar 21, 2017 at 01:46:09PM +0100, Marcin Ciupak wrote:
> > Replace simple_strtoul with kstrtoint.
> > simple_strtoul is marked for obsoletion as reported by checkpatch.pl
> > 
> > Signed-off-by: Marcin Ciupak 
> > ---
> > v2:
> > -improving kstrtoint error handling
> > -updating commit message
> > 
> >  drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 
> >  1 file changed, 12 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c 
> > b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> > index 8e0d4b1d86dc..42858ee5b444 100644
> > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
> > @@ -924,12 +924,20 @@ static int lmd_parse(char *options, struct 
> > lustre_mount_data *lmd)
> > lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
> > clear++;
> > } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
> > -   lmd->lmd_recovery_time_soft = max_t(int,
> > -   simple_strtoul(s1 + 19, NULL, 10), time_min);
> > +   int res;
> > +
> > +   rc = kstrtoint(s1 + 19, 10, &res);
> > +   if (rc)
> > +   goto invalid;
> > +   lmd->lmd_recovery_time_soft = max_t(int, res, time_min);
> 
> Are you sure max_t is still needed here?
> 
> And have you tested this change?
> 
> thanks,
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel