Re: [PATCH 1/4] treewide: convert ISO_8859-1 text comments to utf-8

2018-07-25 Thread Joe Perches
On Wed, 2018-07-25 at 15:12 +0200, Arnd Bergmann wrote:
> tools/perf/tests/.gitignore:
> LLVM byte-codes, uncompressed
> On Wed, Jul 25, 2018 at 2:55 AM, Andrew Morton
>  wrote:
> > On Tue, 24 Jul 2018 17:13:20 -0700 Joe Perches  wrote:
> > 
> > > On Tue, 2018-07-24 at 14:00 -0700, Andrew Morton wrote:
> > > > On Tue, 24 Jul 2018 13:13:25 +0200 Arnd Bergmann  wrote:
> > > > > Almost all files in the kernel are either plain text or UTF-8
> > > > > encoded. A couple however are ISO_8859-1, usually just a few
> > > > > characters in a C comments, for historic reasons.
> > > > > This converts them all to UTF-8 for consistency.
> > > 
> > > []
> > > > Will we be getting a checkpatch rule to keep things this way?
> > > 
> > > How would that be done?
> > 
> > I'm using this, seems to work.
> > 
> > if ! file $p | grep -q -P ", ASCII text|, UTF-8 Unicode text"
> > then
> > echo $p: weird charset
> > fi
> 
> There are a couple of files that my version of 'find' incorrectly identified 
> as
> something completely different, like:
> 
> Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt:
> SemOne archive data
> Documentation/devicetree/bindings/rtc/epson,rtc7301.txt:
> Microsoft Document Imaging Format
> Documentation/filesystems/nfs/pnfs-block-server.txt:
> PPMN archive data
> arch/arm/boot/dts/bcm283x-rpi-usb-host.dtsi:
> Sendmail frozen configuration  - version = "host";
> Documentation/networking/segmentation-offloads.txt:
> StuffIt Deluxe Segment (data) : gmentation Offloads in the
> Linux Networking Stack
> arch/sparc/include/asm/visasm.h:  SAS 7+
> arch/xtensa/kernel/setup.c: ,
> init=0x454c, stat=0x090a, dev=0x2009, bas=0x2020
> drivers/cpufreq/powernow-k8.c:
> TI-XX Graphing Calculator (FLASH)
> tools/testing/selftests/net/forwarding/tc_shblocks.sh:
> Minix filesystem, V2 (big endian)
> tools/perf/tests/.gitignore:
> LLVM byte-codes, uncompressed
> 
> All of the above seem to be valid ASCII or UTF-8 files, so the check
> above will lead
> to false-positives, but it may be good enough as they are the
> exception, and may be
> bugs in 'file'.
> 
> Not sure if we need to worry about 'file' not being installed.

checkpatch works on patches so I think the test isn't
really relevant.  It has to use the appropriate email
header that sets the charset.

perhaps:
---
 scripts/checkpatch.pl | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34e4683de7a3..57355fbd2d28 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2765,9 +2765,13 @@ sub process {
 # Check if there is UTF-8 in a commit log when a mail header has explicitly
 # declined it, i.e defined some charset where it is missing.
if ($in_header_lines &&
-   $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
-   $1 !~ /utf-8/i) {
-   $non_utf8_charset = 1;
+   $rawline =~ /^Content-Type:.+charset="?([^\s;"]+)/) {
+   my $charset = $1;
+   $non_utf8_charset = 1 if ($charset !~ /^utf-8$/i);
+   if ($charset !~ /^(?:us-ascii|utf-8|iso-8859-1)$/) {
+   WARN("PATCH_CHARSET",
+"Unpreferred email header charset 
'$charset'\n" . $herecurr);
+   }
}
 
if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&





[PATCH 08/18] random: Remove pr_fmt duplicate logging prefixes

2018-05-10 Thread Joe Perches
Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/char/hw_random/via-rng.c | 10 +-
 drivers/char/random.c| 16 +++-
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index ffe9b0c6c647..b9367e055468 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -24,6 +24,8 @@
  * warranty of any kind, whether express or implied.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -137,8 +139,7 @@ static int via_rng_init(struct hwrng *rng)
 * register */
if (((c->x86 == 6) && (c->x86_model >= 0x0f))  || (c->x86 > 6)){
if (!boot_cpu_has(X86_FEATURE_XSTORE_EN)) {
-   pr_err(PFX "can't enable hardware RNG "
-   "if XSTORE is not enabled\n");
+   pr_err("can't enable hardware RNG if XSTORE is not 
enabled\n");
return -ENODEV;
}
return 0;
@@ -176,7 +177,7 @@ static int via_rng_init(struct hwrng *rng)
   unneeded */
rdmsr(MSR_VIA_RNG, lo, hi);
if ((lo & VIA_RNG_ENABLE) == 0) {
-   pr_err(PFX "cannot enable VIA C3 RNG, aborting\n");
+   pr_err("cannot enable VIA C3 RNG, aborting\n");
return -ENODEV;
}
 
@@ -202,8 +203,7 @@ static int __init mod_init(void)
pr_info("VIA RNG detected\n");
err = hwrng_register(_rng);
if (err) {
-   pr_err(PFX "RNG registering failed (%d)\n",
-  err);
+   pr_err("RNG registering failed (%d)\n", err);
goto out;
}
 out:
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cd888d4ee605..d1e35cfcce8e 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -693,7 +693,7 @@ static void credit_entropy_bits(struct entropy_store *r, 
int nbits)
}
 
if (unlikely(entropy_count < 0)) {
-   pr_warn("random: negative entropy/overflow: pool %s count %d\n",
+   pr_warn("negative entropy/overflow: pool %s count %d\n",
r->name, entropy_count);
WARN_ON(1);
entropy_count = 0;
@@ -857,7 +857,7 @@ static int crng_fast_load(const char *cp, size_t len)
invalidate_batched_entropy();
crng_init = 1;
wake_up_interruptible(_init_wait);
-   pr_notice("random: fast init done\n");
+   pr_notice("fast init done\n");
}
return 1;
 }
@@ -942,16 +942,14 @@ static void crng_reseed(struct crng_state *crng, struct 
entropy_store *r)
crng_init = 2;
process_random_ready_list();
wake_up_interruptible(_init_wait);
-   pr_notice("random: crng init done\n");
+   pr_notice("crng init done\n");
if (unseeded_warning.missed) {
-   pr_notice("random: %d get_random_xx warning(s) missed "
- "due to ratelimiting\n",
+   pr_notice("%d get_random_xx warning(s) missed due to 
ratelimiting\n",
  unseeded_warning.missed);
unseeded_warning.missed = 0;
}
if (urandom_warning.missed) {
-   pr_notice("random: %d urandom warning(s) missed "
- "due to ratelimiting\n",
+   pr_notice("%d urandom warning(s) missed due to 
ratelimiting\n",
  urandom_warning.missed);
urandom_warning.missed = 0;
}
@@ -1380,7 +1378,7 @@ static size_t account(struct entropy_store *r, size_t 
nbytes, int min,
ibytes = 0;
 
if (unlikely(entropy_count < 0)) {
-   pr_warn("random: negative entropy count: pool %s count %d\n",
+   pr_warn("negative entropy count: pool %s count %d\n",
r->name, entropy_count);
WARN_ON(1);
entropy_count = 0;
@@ -1596,7 +1594,7 @@ static void _warn_unseeded_randomness(const char 
*func_name, void *caller,
print_once = true;
 #endif
if (__ratelimit(_warning))
-   pr_notice("random: %s called from %pS with crng_init=%d\n",
+   pr_notice("%s called from %pS with crng_init=%d\n",
  func_name, caller, crng_init);
 }
 
-- 
2.15.0



[PATCH 00/18] Convert default pr_fmt from empty to KBUILD_MODNAME

2018-05-10 Thread Joe Perches
pr_ logging uses allow a prefix to be specified with a
specific #define pr_fmt

The default of pr_fmt in printk.h is #define pr_fmt(fmt) fmt
so no prefixing of logging output is generically done.

There are several output logging uses like dump_stack() that are
unprefixed and should remain unprefixed.

This patch series attempts to convert the default #define of pr_fmt to
KBUILD_MODNAME ": " fmt and as well update the various bits of the kernel
that should _not_ be prefixed by adding #define pr_fmt(fmt) fmt to those
compilation units that do not want output message prefixing.

There are about 1200 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
that could be removed if the default is changed.

A script that does this removal (and removes any blank lines that follow)
for the linux-kernel tree is included below:

$ git grep -P --name-only "define\s+pr_fmt\b" | \
  grep -v include/linux/printk.h | \
  xargs perl -i -e 'local $/; while (<>) {s/(\n)*[ \t]*#[ \t]*define[ 
\t]+pr_fmt[ \t]*\([ \t]*(\w+)[ \t]*\)[ \t]*KBUILD_MODNAME[ \t]*\": \"[ \t]*\2[ 
\t]*\n\s*/\1\n/; s/^\n//; print;}'

This script should be run after this patch series is applied.

The above script output diff is currently:

1198 files changed, 70 insertions(+), 2241 deletions(-)

Joe Perches (18):
  kernel: Use pr_fmt
  lib: Use pr_fmt
  printk: Convert pr_fmt from blank define to KBUILD_MODNAME
  x86: Remove pr_fmt duplicate logging prefixes
  x86/mtrr: Rename main.c to mtrr.c and remove duplicate prefixes
  net: Remove pr_fmt duplicate logging prefixes
  blk-mq: Remove pr_fmt duplicate logging prefixes
  random: Remove pr_fmt duplicate logging prefixes
  ptp: Remove pr_fmt duplicate logging prefixes
  efifb: Remove pr_fmt duplicate logging prefixes
  proc: Remove pr_fmt duplicate logging prefixes
  uprobes: Remove pr_fmt duplicate logging prefixes
  printk: Remove pr_fmt duplicate logging prefixes
  lib/mpi: Remove pr_fmt duplicate logging prefixes
  security: Remove pr_fmt duplicate logging prefixes
  aoe: Remove pr_fmt duplicate logging prefixes
  security: encrypted-keys: Remove pr_fmt duplicate logging prefixes
  rcu: Use pr_fmt to prefix "rcu: " to logging output

 arch/x86/events/amd/ibs.c  |  2 +-
 arch/x86/kernel/cpu/mtrr/Makefile  |  2 +-
 arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c}| 33 ++---
 arch/x86/kernel/e820.c | 32 ++--
 arch/x86/kernel/hpet.c |  5 +-
 arch/x86/kernel/uprobes.c  |  4 +-
 arch/x86/mm/numa.c | 22 -
 block/blk-mq.c |  9 ++--
 drivers/block/aoe/aoeblk.c | 29 ++-
 drivers/block/aoe/aoechr.c | 11 ++---
 drivers/block/aoe/aoecmd.c | 34 ++---
 drivers/block/aoe/aoedev.c | 19 +++-
 drivers/block/aoe/aoemain.c|  6 +--
 drivers/block/aoe/aoenet.c | 19 +++-
 drivers/char/hw_random/via-rng.c   | 10 ++--
 drivers/char/random.c  | 16 +++---
 drivers/ptp/ptp_clock.c|  4 +-
 drivers/video/fbdev/efifb.c| 48 +-
 fs/proc/root.c |  6 +--
 include/linux/printk.h |  2 +-
 kernel/acct.c  |  2 +
 kernel/async.c | 14 +++---
 kernel/audit_tree.c|  2 +-
 kernel/backtracetest.c |  8 +--
 kernel/crash_core.c| 29 ++-
 kernel/events/uprobes.c|  3 +-
 kernel/exit.c  |  2 +
 kernel/hung_task.c | 13 +++--
 kernel/kprobes.c   | 20 +---
 kernel/module.c| 59 +++
 kernel/panic.c |  3 ++
 kernel/params.c| 13 +++--
 kernel/pid.c   |  2 +
 kernel/printk/printk.c |  2 +-
 kernel/profile.c   |  2 +
 kernel/range.c |  2 +-
 kernel/rcu/rcu_segcblist.c |  2 +
 kernel/rcu/rcuperf.c   | 10 ++--
 kernel/rcu/rcutorture.c| 46 +-
 kernel/rcu/srcutiny.c  |  2 +
 kernel/rcu/srcutree.c  |  5 +-
 kernel/rcu/tiny.c  |  3 ++
 kernel/rcu/tree.c  |  8 +--
 kernel/rcu/tree_plugin.h   | 67 +++---
 kernel/rcu/update.c| 19 +---
 kernel/relay.c |  5 +-
 ker

Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses

2018-03-30 Thread Joe Perches
On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > 
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > > 
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > > 
> > > 
> > > -((i <= c))
> > > +i <= c
> > 
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> > 
> > Why not expression instead of constant?
> 
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
hmm
Perhaps you should use something like this?
@@
identifier i;
constant c;
@@

-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)



Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses

2018-03-28 Thread Joe Perches
On Wed, 2018-03-28 at 23:27 +0530, Varsha Rao wrote:
> This patch fixes the clang warning of extraneous parentheses, with the
> following coccinelle script.
> 
> @@
> identifier i;
> constant c;
> @@
> (
> -((i == c))
> +i == c
> > 
> 
> -((i <= c))
> +i <= c

Why just the "==" and "<=" cases?
Why not "<", ">" and ">=" too?

Why not expression instead of constant?



Re: [PATCH 3/4] crypto: bcm: Constify *hash_alg_name[]

2018-03-09 Thread Joe Perches
On Fri, 2018-03-09 at 22:29 +0800, Herbert Xu wrote:
> On Tue, Feb 27, 2018 at 07:01:27PM -0300, Hernán Gonzalez wrote:
> > Note: This is compile only tested.
> > No gain from this except some self-documenting.
[]
> > diff --git a/drivers/crypto/bcm/spu.c b/drivers/crypto/bcm/spu.c
[]
> > @@ -23,8 +23,9 @@
> >  #include "cipher.h"
> >  
> >  /* This array is based on the hash algo type supported in spu.h */
> > -char *hash_alg_name[] = { "None", "md5", "sha1", "sha224", "sha256", "aes",
> > -   "sha384", "sha512", "sha3_224", "sha3_256", "sha3_384", "sha3_512" };
> > +char const * const hash_alg_name[] = { "None", "md5", "sha1", "sha224",
> 
> Please make that
> 
>   const char *const
> 
> Ditto with patch 4.
> 
> Thanks,

and likely, as this is a global name, it should
be something like crypto_hash_alg_name



Re: [PATCH] staging: ccree: shorten lengthy lines with breaks

2018-01-06 Thread Joe Perches
On Sat, 2018-01-06 at 15:47 +, George Edward Bulmer wrote:
> This fixes five instances of checkpatch warning:
> WARNING: line over 80 characters
[]
> diff --git a/drivers/staging/ccree/ssi_sysfs.c 
> b/drivers/staging/ccree/ssi_sysfs.c
[]
> @@ -32,15 +32,26 @@ static ssize_t ssi_sys_regdump_show(struct kobject *kobj,
>   int offset = 0;
>  
>   register_value = cc_ioread(drvdata, CC_REG(HOST_SIGNATURE));
> - offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 
> 0x%08X\n", "HOST_SIGNATURE   ", DX_HOST_SIGNATURE_REG_OFFSET, 
> register_value);
> + offset += scnprintf(buf + offset, PAGE_SIZE - offset,
> + "%s \t(0x%lX)\t 0x%08X\n", "HOST_SIGNATURE   ",

trivia:

Using %-21s would do the same as padding the format
string argument and would create smaller object code.

offset += scnprintf(buf + offset, PAGE_SIZE - offset,
"%-21s \t(0x%lX)\t 0x%08X\n", "HOST_SIGNATURE",

Using an extra space before a tab is odd.

Using a space after a tab is odd too.

> + DX_HOST_SIGNATURE_REG_OFFSET, register_value);
>   register_value = cc_ioread(drvdata, CC_REG(HOST_IRR));
> - offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 
> 0x%08X\n", "HOST_IRR ", DX_HOST_IRR_REG_OFFSET, register_value);
> + offset += scnprintf(buf + offset, PAGE_SIZE - offset,
> + "%s \t(0x%lX)\t 0x%08X\n", "HOST_IRR ",

etc...

> + DX_HOST_IRR_REG_OFFSET, register_value);
>   register_value = cc_ioread(drvdata, CC_REG(HOST_POWER_DOWN_EN));
> - offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 
> 0x%08X\n", "HOST_POWER_DOWN_EN   ", DX_HOST_POWER_DOWN_EN_REG_OFFSET, 
> register_value);
> + offset += scnprintf(buf + offset, PAGE_SIZE - offset,
> + "%s \t(0x%lX)\t 0x%08X\n", "HOST_POWER_DOWN_EN   ",
> + DX_HOST_POWER_DOWN_EN_REG_OFFSET, register_value);
>   register_value =  cc_ioread(drvdata, CC_REG(AXIM_MON_ERR));
> - offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 
> 0x%08X\n", "AXIM_MON_ERR ", DX_AXIM_MON_ERR_REG_OFFSET, 
> register_value);
> + offset += scnprintf(buf + offset, PAGE_SIZE - offset,
> + "%s \t(0x%lX)\t 0x%08X\n", "AXIM_MON_ERR ",
> + DX_AXIM_MON_ERR_REG_OFFSET, register_value);
>   register_value = cc_ioread(drvdata, CC_REG(DSCRPTR_QUEUE_CONTENT));
> - offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s \t(0x%lX)\t 
> 0x%08X\n", "DSCRPTR_QUEUE_CONTENT", DX_DSCRPTR_QUEUE_CONTENT_REG_OFFSET, 
> register_value);
> + offset += scnprintf(buf + offset, PAGE_SIZE - offset,
> + "%s \t(0x%lX)\t 0x%08X\n", "DSCRPTR_QUEUE_CONTENT",
> + DX_DSCRPTR_QUEUE_CONTENT_REG_OFFSET,
> + register_value);
>   return offset;
>  }
>  


Re: [PATCH] crypto: testmgr: change `guard` to unsigned char

2018-01-01 Thread Joe Perches
On Mon, 2018-01-01 at 00:33 -1000, Joey Pabalinas wrote:
> When char is signed, storing the values 0xba (186) and 0xad (173) in the
> `guard` array produces signed overflow. Change the type of `guard` to
> unsigned char to remove undefined behavior.
[]
> diff --git a/crypto/testmgr.c b/crypto/testmgr.c
[]
> @@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request 
> **preq,
>   char *state;
>   struct ahash_request *req;
>   int statesize, ret = -EINVAL;
> - const char guard[] = { 0x00, 0xba, 0xad, 0x00 };
> + const unsigned char guard[] = { 0x00, 0xba, 0xad, 0x00 };

Might as well add static too



Re: [PATCH] crypto: Use zeroing memory allocator instead of allocator/memset

2017-12-31 Thread Joe Perches
On Sun, 2017-12-31 at 17:54 +0530, Himanshu Jha wrote:
> Use dma_zalloc_coherent for allocating zeroed
> memory and remove unnecessary memset function.
> 
> Done using Coccinelle.
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

I thought you were going to change this tag to
not use the "-by:" form and use something else
like "generated-using:" or "created-with:".



Re: [PATCH] checkpatch: add *_ON_STACK to $declaration_macros

2017-12-20 Thread Joe Perches
On Tue, 2017-06-27 at 10:55 +0300, Gilad Ben-Yossef wrote:
> Add the crypto API *_ON_STACK to $declaration_macros.
> 
> Resolves the following false warning:
> 
> WARNING: Missing a blank line after declarations
> + int err;
> + SHASH_DESC_ON_STACK(desc, ctx_p->shash_tfm);
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -733,6 +733,7 @@ our $FuncArg = 
> qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
>  our $declaration_macros = qr{(?x:
>   
> (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(|
>   (?:$Storage\s+)?LIST_HEAD\s*\(|
> + (?:$Storage\s+)?[A-Z_]*_ON_STACK\(|

A few things:

The crypto _ON_STACK declarations cannot have a $Storage type.

There should be a \s* between the ON_STACK and the open parenthesis

There are other _ON_STACK types than the crypto uses

$ grep -rP --include=*.[ch] -oh "\b[A-Z_]+_ON_STACK\b" * | \
  sort | uniq -c | sort -rn
 68 SKCIPHER_REQUEST_ON_STACK
 45 SHASH_DESC_ON_STACK
 10 AHASH_REQUEST_ON_STACK
  4 PC_LOC_ON_STACK
  4 DECLARE_DPM_WATCHDOG_ON_STACK
  3 HISI_SAS_DECLARE_RST_WORK_ON_STACK
  3 CONFIG_ARCH_TASK_STRUCT_ON_STACK
  1 PT_SIZE_ON_STACK
  1 ALLOC_PT_GPREGS_ON_STACK

So perhaps:

(?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\(



Re: [PATCH 1/3] crypto: exynos - Support Exynos5250+ SoCs

2017-12-06 Thread Joe Perches
On Wed, 2017-12-06 at 15:05 +0100, Krzysztof Kozlowski wrote:
> On Wed, Dec 6, 2017 at 2:42 PM, Łukasz Stelmach  
> wrote:
> > It was <2017-12-05 wto 14:34>, when Krzysztof Kozlowski wrote:
> > > On Tue, Dec 5, 2017 at 1:35 PM, Łukasz Stelmach  
> > > wrote:
> > > > Add support for PRNG in Exynos5250+ SoCs.
[]
> > > > diff --git a/drivers/crypto/exynos-rng.c b/drivers/crypto/exynos-rng.c
[]
> > > > @@ -300,7 +323,10 @@ static int exynos_rng_probe(struct platform_device 
> > > > *pdev)
> > > > dev_err(>dev,
> > > > "Couldn't register rng crypto alg: %d\n", ret);
> > > > exynos_rng_dev = NULL;
> > > > -   }
> > > > +   } else
> > > 
> > > Missing {} around else clause. Probably checkpatch should point it.
> > 
> > It doesn't. Fixed.

checkpatch does report this if using --strict

$ ./scripts/checkpatch.pl --strict -
CHECK: Unbalanced braces around else statement
#119: FILE: drivers/crypto/exynos-rng.c:326:
+   } else

Arguably, this should always be reported.


Re: [PATCH] treewide: remove duplicate includes

2017-12-03 Thread Joe Perches
On Mon, 2017-12-04 at 03:19 +0530, Pravin Shedge wrote:
> These duplicate includes have been found with scripts/checkincludes.pl but
> they have been removed manually to avoid removing false positives.

Can you list the duplicates that were not removed as well please?



Re: [PATCH 07/24] staging: ccree: remove unneeded cast

2017-11-13 Thread Joe Perches
On Mon, 2017-11-13 at 14:45 +, Gilad Ben-Yossef wrote:
> Remove uneeded cast from writel_relaxed parameter.
[]
> diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
> b/drivers/staging/ccree/ssi_request_mgr.c
[]
> @@ -167,13 +167,13 @@ static inline void enqueue_seq(
>   int i;
>  
>   for (i = 0; i < seq_len; i++) {
> - writel_relaxed(seq[i].word[0], (volatile void __iomem 
> *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
> - writel_relaxed(seq[i].word[1], (volatile void __iomem 
> *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
> - writel_relaxed(seq[i].word[2], (volatile void __iomem 
> *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
> - writel_relaxed(seq[i].word[3], (volatile void __iomem 
> *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
> - writel_relaxed(seq[i].word[4], (volatile void __iomem 
> *)(cc_base + CC_REG(DSCRPTR_QUEUE_WORD0)));
> + writel_relaxed(seq[i].word[0], (cc_base + 
> CC_REG(DSCRPTR_QUEUE_WORD0)));

Maybe remove the now unnecessary parentheses around
(cc_case + CC_REG(foo))

Maybe review the use of inline in .c files too

$ git grep -w inline drivers/staging/ccree/*.c | wc -l
41



Re: [PATCH] staging: ccree: Fix indentation in ssi_buffer_mgr.c

2017-10-27 Thread Joe Perches
On Fri, 2017-10-27 at 11:32 +0300, Dan Carpenter wrote:
> On Thu, Oct 26, 2017 at 06:53:42PM -0700, Stephen Brennan wrote:
> > In particular, fixes some over-indented if statement bodies as well as a
> > couple lines indented with spaces. checkpatch.pl now reports no warnings
> > on this file other than 80 character warnings.
[]
> > diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c 
> > b/drivers/staging/ccree/ssi_buffer_mgr.c
[]
> > @@ -1029,10 +1029,10 @@ static inline int 
> > ssi_buffer_mgr_prepare_aead_data_mlli(
> >  * verification is made by CPU compare in order to 
> > simplify
> >  * MAC verification upon request completion
> >  */
> > - u32 size_to_skip = req->assoclen;
> > +   u32 size_to_skip = req->assoclen;
> >  
> > - if (areq_ctx->is_gcm4543)
> > - size_to_skip += crypto_aead_ivsize(tfm);
> > +   if (areq_ctx->is_gcm4543)
> > +   size_to_skip += crypto_aead_ivsize(tfm);
> >  
> >   ssi_buffer_mgr_copy_scatterlist_portion(
> > dev, areq_ctx->backup_mac, req->src,
> 
> But then ssi_buffer_mgr_copy_scatterlist_portion() is still not indented
> correctly.

The latest version of checkpatch should bleat something on the
...scatterlist_portion(
line


Re: [PATCH] staging: ccree: local variable "dev" not required

2017-10-05 Thread Joe Perches
On Thu, 2017-10-05 at 10:07 +0300, Gilad Ben-Yossef wrote:
> On Wed, Oct 4, 2017 at 10:12 PM,   wrote:
> > There is no need to create a local pointer variable "dev" and
> > pass it various API's, instead use plat_dev which is enumerated
> > by platform core on successful probe.
[]
> I'm sorry but I don't understand what is the problem you are trying to solve 
> or
> what is the improvement suggested.
> 
> Why is having a local variable undesirable? I think having it makes
> the code more readable, not less.

IMO: The local variable is _not_ undesirable.
 It does make the code more readable and
 shortens line lengths too.


Re: [PATCH 2/4] staging: ccree: simplify access to struct device

2017-10-02 Thread Joe Perches
On Mon, 2017-10-02 at 10:03 +0100, Gilad Ben-Yossef wrote:
> Introduce a DEV macro to retrieve struct device from private
> data structure in preparation to replacing custom logging
> macros with proper dev_dbg and friends which require struct
> device.
[]
> diff --git a/drivers/staging/ccree/ssi_driver.h 
> b/drivers/staging/ccree/ssi_driver.h
[]
> @@ -103,6 +103,8 @@
>  #define SSI_LOG_DEBUG(format, ...) do {} while (0)
>  #endif
>  
> +#define DEV(drvdata) ((&(drvdata)->plat_dev->dev))

The name seems not particularly descriptive.
It seems a longer name would
not be too bad.

Perhaps

static inline struct device *drvdata_to_dev(struct ssi_drvdata *drvdata)
{
return >plat_dev->dev;
}



[PATCH] staging: ccree: Add missing newlines

2017-09-10 Thread Joe Perches
Logging without newlines are still prone to interleaving.
Add newlines where necessary.

Miscellanea:

o Coalesce formats
o Realign arguments
o Fix a couple misindented lines with the above logging changes

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/staging/ccree/ssi_aead.c|  17 ++--
 drivers/staging/ccree/ssi_buffer_mgr.c  | 135 ++--
 drivers/staging/ccree/ssi_cipher.c  |  40 +-
 drivers/staging/ccree/ssi_driver.c  |   6 +-
 drivers/staging/ccree/ssi_hash.c|  47 +--
 drivers/staging/ccree/ssi_ivgen.c   |   8 +-
 drivers/staging/ccree/ssi_request_mgr.c |  15 ++--
 drivers/staging/ccree/ssi_sram_mgr.c|   2 +-
 8 files changed, 122 insertions(+), 148 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 5abe6b24ff8c..61ecfe59195a 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) {
@@ -1861,7 +1860,7 @@ static inline void ssi_aead_dump_gcm(
return;
 
if (title) {
-   
SSI_LOG_DEBUG("--");
+   
SSI_LOG_DEBUG("--\n");
SSI_LOG_DEBUG("%s\n", title);
}
 
@@ -2017,7 +2016,8 @@ static int ssi_aead_process(struct aead_request *req, 
enum drv_crypto_direction
if (ctx->cipher_mode == DRV_CIPHER_CCM) {
rc = config_ccm_adata(req);
if (unlikely(rc != 0)) {
-   SSI_LOG_ERR("config_ccm_adata() returned with a failure 
%d!", rc);
+   SSI_LOG_ERR("config_ccm_adata() returned with a failure 
%d!\n",
+   rc);
goto exit;
}
} else {
@@ -2031,7 +2031,8 @@ static int ssi_aead_process(struct aead_request *req, 
enum drv_crypto_direction
if (ctx->cipher_mode == DRV_CIPHER_GCTR) {
rc = config_gcm_context(req);
if (unlikely(rc != 0)) {
-   SSI_LOG_ERR("config_gcm_context() returned with a 
failure %d!", rc);
+   SSI_LOG_ERR("config_gcm_context() returned with a 
failure %d!\n",
+   rc);
goto exit;
}
}
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c 
b/drivers/staging/ccree/ssi_buffer_mgr.c
index 63936091d524..d41ec19856bf 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,10 @@ static int ssi_buffer_mgr_generate_mlli(
/* Set MLLI size for the bypass operation */
  

Re: [PATCH v3] Staging: ccree: ssi_cipher.c: Remove unused variable.

2017-09-07 Thread Joe Perches
On Thu, 2017-09-07 at 00:32 +0300, Dan Carpenter wrote:
> Always compile your patches.
> 
>   CC [M]  drivers/staging/ccree/ssi_cipher.o
> drivers/staging/ccree/ssi_cipher.c: In function ‘ssi_blkcipher_complete’:
> drivers/staging/ccree/ssi_cipher.c:700:6: warning: unused variable 
> ‘inflight_counter’ [-Wunused-variable]
>   u32 inflight_counter;
>   ^~~~
> 
> You need to delete the declaration as well.
> 
> Don't be in a rush to resend patches.  I normally write them then let
> them sit in my outbox overnight and send them in the morning.  The extra
> delay helps me to calm down a bit and focus better.  Even though I've
> sent thousands of patches, it sometimes still stresses me out.  It's
> like you're disagreeing with the original author and the reviewers are
> disagreeing with you and everyone's trying to be nice about it but
> patches are fundamentally points of disagreement and that's stress.

True, and you shouldn't add a blank link either.
there's already one above the block you deleted.


Re: [PATCH v3 11/22] staging: ccree: fix line indentation and breaks

2017-08-15 Thread Joe Perches
On Tue, 2017-08-15 at 09:26 +0300, Gilad Ben-Yossef wrote:
> Fix wrong indentation and line breaks, including missing tabs,
> breaking lines longer then 80 char or wrongly broken.
[]
> diff --git a/drivers/staging/ccree/ssi_driver.c 
> b/drivers/staging/ccree/ssi_driver.c
[]
> - SSI_LOG_ERR("snprintf returned %d . aborting buffer 
> array dump\n", ret);
> + SSI_LOG_ERR
> + ("snprintf returned %d . aborting buffer array 
> dump\n",
> +  ret);

This change is quite unpleasant to read.



Re: [PATCH V2] staging: ccree: Fix format/argument mismatches

2017-08-03 Thread Joe Perches
On Thu, 2017-08-03 at 17:09 +0800, kbuild test robot wrote:
> Hi Joe,
> 
> [auto build test WARNING on staging/staging-testing]
> [also build test WARNING on next-20170803]
> [cannot apply to v4.13-rc3]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]

Pretty odd that m32r has ioread32 as _readl and so unsigned long
Seems silly to have to cast it.

Gilad, is this actually a supported platform for ccree?

> url:
> https://github.com/0day-ci/linux/commits/Joe-Perches/staging-ccree-Fix-format-argument-mismatches/20170731-191055
> config: m32r-allmodconfig (attached as .config)
> compiler: m32r-linux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=m32r 
> 
> All warnings (new ones prefixed by >>):
> 
>In file included from include/linux/kernel.h:13:0,
> from drivers/staging/ccree/ssi_driver.c:17:
>drivers/staging/ccree/ssi_driver.c: In function 'init_cc_regs':
> > > drivers/staging/ccree/ssi_driver.c:180:16: warning: format '%X' expects 
> > > argument of type 'unsigned int', but argument 2 has type 'long unsigned 
> > > int' [-Wformat=]
> 
>  SSI_LOG_DEBUG("AXIM_CFG=0x%08X\n", 
> CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG)));




[PATCH V2] staging: ccree: Fix format/argument mismatches

2017-07-31 Thread Joe Perches
By default, debug logging is disabled by CC_DEBUG not being defined.

Convert SSI_LOG_DEBUG to use no_printk instead of an empty define
to validate formats and arguments.

Fix fallout.

Miscellanea:

o One of the conversions now uses %pR instead of multiple uses of %pad

Signed-off-by: Joe Perches <j...@perches.com>
---

On top of next-20170731

 drivers/staging/ccree/ssi_aead.c|  8 
 drivers/staging/ccree/ssi_buffer_mgr.c  | 29 +---
 drivers/staging/ccree/ssi_cipher.c  | 10 +-
 drivers/staging/ccree/ssi_driver.c  |  5 ++---
 drivers/staging/ccree/ssi_driver.h  |  2 +-
 drivers/staging/ccree/ssi_hash.c| 34 -
 drivers/staging/ccree/ssi_request_mgr.c |  6 +++---
 7 files changed, 45 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index f5ca0e35c5d3..6664ade43b70 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -103,7 +103,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
if (ctx->enckey) {
dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey, 
ctx->enckey_dma_addr);
SSI_LOG_DEBUG("Freed enckey DMA buffer enckey_dma_addr=%pad\n",
- ctx->enckey_dma_addr);
+ >enckey_dma_addr);
ctx->enckey_dma_addr = 0;
ctx->enckey = NULL;
}
@@ -117,7 +117,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
  xcbc->xcbc_keys_dma_addr);
}
SSI_LOG_DEBUG("Freed xcbc_keys DMA buffer 
xcbc_keys_dma_addr=%pad\n",
- xcbc->xcbc_keys_dma_addr);
+ >xcbc_keys_dma_addr);
xcbc->xcbc_keys_dma_addr = 0;
xcbc->xcbc_keys = NULL;
} else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */
@@ -128,7 +128,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
  hmac->ipad_opad,
  hmac->ipad_opad_dma_addr);
SSI_LOG_DEBUG("Freed ipad_opad DMA buffer 
ipad_opad_dma_addr=%pad\n",
- hmac->ipad_opad_dma_addr);
+ >ipad_opad_dma_addr);
hmac->ipad_opad_dma_addr = 0;
hmac->ipad_opad = NULL;
}
@@ -137,7 +137,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
  hmac->padded_authkey,
  hmac->padded_authkey_dma_addr);
SSI_LOG_DEBUG("Freed padded_authkey DMA buffer 
padded_authkey_dma_addr=%pad\n",
- hmac->padded_authkey_dma_addr);
+ >padded_authkey_dma_addr);
hmac->padded_authkey_dma_addr = 0;
hmac->padded_authkey = NULL;
}
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c 
b/drivers/staging/ccree/ssi_buffer_mgr.c
index 63936091d524..88b36477ce6d 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -14,6 +14,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -33,14 +34,10 @@
 #include "ssi_hash.h"
 #include "ssi_aead.h"
 
-#ifdef CC_DEBUG
 #define GET_DMA_BUFFER_TYPE(buff_type) ( \
((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \
((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \
((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID")
-#else
-#define GET_DMA_BUFFER_TYPE(buff_type)
-#endif
 
 enum dma_buffer_type {
DMA_NULL_TYPE = -1,
@@ -262,7 +259,7 @@ static int ssi_buffer_mgr_generate_mlli(
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,
+  _params->mlli_dma_addr,
   mlli_params->mlli_len);
 
 build_mlli_exit:
@@ -278,7 +275,7 @@ static inline void ssi_buffer_mgr_add_buffer_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);
+index, _dma, buffer_len, is_last_entry);
sgl_data->nents[index] = 1;
sgl_data->entry[index].buffer_dma = buffer_dma;
sgl_data->offset[index] = 0;
@@ -362,7 +359,7 @@ stati

Re: [PATCH] staging: ccree: Fix format/argument mismatches

2017-07-31 Thread Joe Perches
On Mon, 2017-07-31 at 09:39 +0300, Gilad Ben-Yossef wrote:
> On Sun, Jul 30, 2017 at 7:45 PM, Joe Perches <j...@perches.com> wrote:
> > By default, debug logging is disabled by CC_DEBUG not being defined.
> > 
> > Convert SSI_LOG_DEBUG to use no_printk instead of an empty define
> > to validate formats and arguments.
> > 
> > Fix fallout.
> > 
> > Miscellanea:
> > 
> > o One of the conversions now uses %pR instead of multiple uses of %pad
> 
> This looks great (I didn't know about no_printk) but does not seem to
> apply on top of
> staging-next.

Applies to next-20170728

b2cf822e075f7a7e7ced8c50af600f9edf5ccc31



[PATCH] staging: ccree: Fix format/argument mismatches

2017-07-30 Thread Joe Perches
By default, debug logging is disabled by CC_DEBUG not being defined.

Convert SSI_LOG_DEBUG to use no_printk instead of an empty define
to validate formats and arguments.

Fix fallout.

Miscellanea:

o One of the conversions now uses %pR instead of multiple uses of %pad

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/staging/ccree/ssi_aead.c|  8 
 drivers/staging/ccree/ssi_buffer_mgr.c  | 29 +
 drivers/staging/ccree/ssi_cipher.c  | 10 +-
 drivers/staging/ccree/ssi_driver.c  |  5 ++---
 drivers/staging/ccree/ssi_driver.h  |  2 +-
 drivers/staging/ccree/ssi_hash.c| 32 
 drivers/staging/ccree/ssi_request_mgr.c |  6 +++---
 7 files changed, 44 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index ea29b8a1a71d..9376bf8b8c61 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -103,7 +103,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
if (ctx->enckey) {
dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey, 
ctx->enckey_dma_addr);
SSI_LOG_DEBUG("Freed enckey DMA buffer enckey_dma_addr=%pad\n",
- ctx->enckey_dma_addr);
+ >enckey_dma_addr);
ctx->enckey_dma_addr = 0;
ctx->enckey = NULL;
}
@@ -117,7 +117,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
  xcbc->xcbc_keys_dma_addr);
}
SSI_LOG_DEBUG("Freed xcbc_keys DMA buffer 
xcbc_keys_dma_addr=%pad\n",
- xcbc->xcbc_keys_dma_addr);
+ >xcbc_keys_dma_addr);
xcbc->xcbc_keys_dma_addr = 0;
xcbc->xcbc_keys = NULL;
} else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */
@@ -128,7 +128,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
  hmac->ipad_opad,
  hmac->ipad_opad_dma_addr);
SSI_LOG_DEBUG("Freed ipad_opad DMA buffer 
ipad_opad_dma_addr=%pad\n",
- hmac->ipad_opad_dma_addr);
+ >ipad_opad_dma_addr);
hmac->ipad_opad_dma_addr = 0;
hmac->ipad_opad = NULL;
}
@@ -137,7 +137,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
  hmac->padded_authkey,
  hmac->padded_authkey_dma_addr);
SSI_LOG_DEBUG("Freed padded_authkey DMA buffer 
padded_authkey_dma_addr=%pad\n",
- hmac->padded_authkey_dma_addr);
+ >padded_authkey_dma_addr);
hmac->padded_authkey_dma_addr = 0;
hmac->padded_authkey = NULL;
}
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c 
b/drivers/staging/ccree/ssi_buffer_mgr.c
index 6579a54f9dc4..e13184d1d165 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -14,6 +14,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -33,14 +34,10 @@
 #include "ssi_hash.h"
 #include "ssi_aead.h"
 
-#ifdef CC_DEBUG
 #define GET_DMA_BUFFER_TYPE(buff_type) ( \
((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \
((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \
((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID")
-#else
-#define GET_DMA_BUFFER_TYPE(buff_type)
-#endif
 
 enum dma_buffer_type {
DMA_NULL_TYPE = -1,
@@ -262,7 +259,7 @@ static int ssi_buffer_mgr_generate_mlli(
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,
+  _params->mlli_dma_addr,
   mlli_params->mlli_len);
 
 build_mlli_exit:
@@ -278,7 +275,7 @@ static inline void ssi_buffer_mgr_add_buffer_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);
+index, _dma, buffer_len, is_last_entry);
sgl_data->nents[index] = 1;
sgl_data->entry[index].buffer_dma = buffer_dma;
sgl_data->offset[index] = 0;
@@ -362,7 +359,7 @@ stati

Re: [PATCH 01/11] Fix coding style of driver/staging/ccree/ssi_aead.c ERROR: space required after that

2017-06-20 Thread Joe Perches
On Tue, 2017-06-20 at 11:20 +0300, Dan Carpenter wrote:
> On Tue, Jun 20, 2017 at 01:19:44PM +0800, Jhih-Ming Huang wrote:
[]
> > In this series patches, I fix all of the coding style error in 
> > driver/staging/ccree/ssi_aead.c from 54 errors to 0 error.
> 
> You could put this into the cover letter.  When we put this into the
> final git log we don't see the series only individual patches.

Which sometimes is a pity as the cover letter can contain
useful information which can easily be added in a merge.



Re: [PATCH][crypto-next] crypto: cavium: fix spelling mistake "Revsion" -> "Revision"

2017-06-13 Thread Joe Perches
On Tue, 2017-06-13 at 11:40 +0100, Colin Ian King wrote:
> On 13/06/17 11:36, Joe Perches wrote:
> > On Tue, 2017-06-13 at 09:52 +0100, Colin King wrote:
> > > From: Colin Ian King <colin.k...@canonical.com>
> > > 
> > > Trivial fix to spelling mistake in seq_printf message
> > Fixing spelling typos is a good thing, but is it a
> > good thing to change possibly API dependent output
> > in seq_ calls?
> Considering it's in -next and has not landed in upstream I supposed it
> was better to fix it now before it landed in Linus' repo.

Good call, thanks.

> > > diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c 
> > > b/drivers/crypto/cavium/nitrox/nitrox_main.c
> > 
> > []
> > > @@ -399,7 +399,7 @@ static int nitrox_show(struct seq_file *s, void *v)
> > >   struct nitrox_device *ndev = s->private;
> > >  
> > >   seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
> > > - seq_printf(s, "  Revsion ID: 0x%0x\n", ndev->hw.revision_id);
> > > + seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
> > >   seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
> > >  ndev->hw.ae_cores, ndev->hw.se_cores);
> > >   seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);


Re: [PATCH][crypto-next] crypto: cavium: fix spelling mistake "Revsion" -> "Revision"

2017-06-13 Thread Joe Perches
On Tue, 2017-06-13 at 09:52 +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in seq_printf message

Hey Colin.

Fixing spelling typos is a good thing, but is it a
good thing to change possibly API dependent output
in seq_ calls?

> diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c 
> b/drivers/crypto/cavium/nitrox/nitrox_main.c
[]
> @@ -399,7 +399,7 @@ static int nitrox_show(struct seq_file *s, void *v)
>   struct nitrox_device *ndev = s->private;
>  
>   seq_printf(s, "NITROX-5 [idx: %d]\n", ndev->idx);
> - seq_printf(s, "  Revsion ID: 0x%0x\n", ndev->hw.revision_id);
> + seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
>   seq_printf(s, "  Cores [AE: %u  SE: %u]\n",
>  ndev->hw.ae_cores, ndev->hw.se_cores);
>   seq_printf(s, "  Number of Queues: %u\n", ndev->nr_queues);


Re: [PATCH v2 01/20] staging: ccree: remove spurious blank lines

2017-06-01 Thread Joe Perches
On Thu, 2017-06-01 at 04:20 -0700, Joe Perches wrote:
> On Thu, 2017-06-01 at 14:02 +0300, Gilad Ben-Yossef wrote:
> > Remove spurious blanks lines from cc_crypto_ctx.h file
> 
> unrelated trivia:
> 
> > diff --git a/drivers/staging/ccree/cc_crypto_ctx.h 
> > b/drivers/staging/ccree/cc_crypto_ctx.h
> 
> []
> > @@ -208,7 +204,6 @@ struct drv_ctx_generic {
> > enum drv_crypto_alg alg;
> >  } __attribute__((__may_alias__));
> 
> Please try to remove the __may_alias__ attribute one day.

That might be easy as struct drv_ctx_generic
is not directly used anywhere.


Re: [PATCH v2 01/20] staging: ccree: remove spurious blank lines

2017-06-01 Thread Joe Perches
On Thu, 2017-06-01 at 14:02 +0300, Gilad Ben-Yossef wrote:
> Remove spurious blanks lines from cc_crypto_ctx.h file

unrelated trivia:

> diff --git a/drivers/staging/ccree/cc_crypto_ctx.h 
> b/drivers/staging/ccree/cc_crypto_ctx.h
[]
> @@ -208,7 +204,6 @@ struct drv_ctx_generic {
>   enum drv_crypto_alg alg;
>  } __attribute__((__may_alias__));

Please try to remove the __may_alias__ attribute one day.


Re: [PATCH 01/12] staging: ccree: correct coding style violations

2017-05-29 Thread Joe Perches
On Mon, 2017-05-29 at 20:11 +0300, Gilad Ben-Yossef wrote:
> On Mon, May 29, 2017 at 7:57 PM, Joe Perches <j...@perches.com> wrote:
> > On Mon, 2017-05-29 at 16:37 +0200, Greg Kroah-Hartman wrote:
> > > On Sun, May 28, 2017 at 05:40:26PM +0300, Gilad Ben-Yossef wrote:
> > > > cc_crypto_ctx.h had multiple coding style violations reported by
> > > > checkpatch. Fix them all.
> > > 
> > > Sorry, no.  You need to do only one-thing-per-patch, and "fix all coding
> > > style issues is not "one thing".  I wouldn't take this kind of patch
> > > from anyone else, so why should I take it from you?  :)
> > 
> > Because he's the named MAINTAINER of the subsystem
> > and you are acting as an upstream conduit.
> > 
> 
> LOL. Thank you Joe, but I have opted to upstream via staging to get the 
> guidance
> and review of Greg and other developers kind enough to offer it, and I'd be a
> fool not to listen to them.

For reviews of technical merit, true.

For reviews of commit log wording of whitespace
changes, where git diff -w shows no difference,
less true.

This patch seems almost entirely whitespace except
one bit reformatting a comment block.

Breaking those down into changes like:
added space after commas
added spaces around bit shifts
added spaces around arithmetic
is simply excessive.

The only comment I would have given would be to
change the patch context that added line comment
initiators to use the /** kernel-doc style.

And maybe a style change of

#define CC_MULTI2_SYSTEM_N_DATA_KEY_SIZE (CC_MULTI2_SYSTEM_KEY_SIZE + \
  CC_MULTI2_DATA_KEY_SIZE)

to 

#define CC_MULTI2_SYSTEM_N_DATA_KEY_SIZE \
(CC_MULTI2_SYSTEM_KEY_SIZE + CC_MULTI2_DATA_KEY_SIZE)

as it's sometimes easier to scan arithmetic on a single line.

btw: this #define seems misleading as it's used in both .min_keysize
and .max_keysize with "+ 1" and key[CC_MULTI2_SYSTEM_N_DATA_KEY_SIZE]
is also used.



Re: [PATCH 01/12] staging: ccree: correct coding style violations

2017-05-29 Thread Joe Perches
On Mon, 2017-05-29 at 16:37 +0200, Greg Kroah-Hartman wrote:
> On Sun, May 28, 2017 at 05:40:26PM +0300, Gilad Ben-Yossef wrote:
> > cc_crypto_ctx.h had multiple coding style violations reported by
> > checkpatch. Fix them all.
> 
> Sorry, no.  You need to do only one-thing-per-patch, and "fix all coding
> style issues is not "one thing".  I wouldn't take this kind of patch
> from anyone else, so why should I take it from you?  :)

Because he's the named MAINTAINER of the subsystem
and you are acting as an upstream conduit.



Re: [PATCH 1/2] crypto: engine - replace pr_xxx by dev_xxx

2017-05-23 Thread Joe Perches
On Tue, 2017-05-23 at 14:09 +0200, Corentin Labbe wrote:
> By adding a struct device *dev to struct engine, we could store the
> device used at register time and so use all dev_xxx functions instead of
> pr_xxx.

trivia:

> diff --git a/include/crypto/engine.h b/include/crypto/engine.h
[]
> @@ -58,6 +58,7 @@ struct crypto_engine {
>   struct list_headlist;
>   spinlock_t  queue_lock;
>   struct crypto_queue queue;
> + struct device *dev;

Probably nicer to align to column for consistency

struct device   *dev;


Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

2017-04-21 Thread Joe Perches
On Fri, 2017-04-21 at 19:36 +0800, Herbert Xu wrote:
> On Wed, Apr 19, 2017 at 11:11:35AM +0200, SF Markus Elfring wrote:
> > From: Markus Elfring 
> > Date: Wed, 19 Apr 2017 10:50:04 +0200
> > 
> > The script "checkpatch.pl" pointed information out like the following.
> > 
> > WARNING: quoted string split across lines
> > 
> > Thus fix the affected source code places.
> > 
> > Signed-off-by: Markus Elfring 
> 
> This patch doesn't seem to add any value so I'm not taking it.

Your choice.

The general reason to merge strings is in CodingStyle

2) Breaking long lines and strings
[]
never break user-visible strings such as
printk messages, because that breaks the ability to grep for them.




Re: [PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn

2017-02-23 Thread Joe Perches
On Thu, 2017-02-23 at 17:41 +, Emil Velikov wrote:
> On 23 February 2017 at 17:18, Joe Perches <j...@perches.com> wrote:
> > On Thu, 2017-02-23 at 09:28 -0600, Rob Herring wrote:
> > > On Fri, Feb 17, 2017 at 1:11 AM, Joe Perches <j...@perches.com> wrote:
> > > > There are ~4300 uses of pr_warn and ~250 uses of the older
> > > > pr_warning in the kernel source tree.
> > > > 
> > > > Make the use of pr_warn consistent across all kernel files.
> > > > 
> > > > This excludes all files in tools/ as there is a separate
> > > > define pr_warning for that directory tree and pr_warn is
> > > > not used in tools/.
> > > > 
> > > > Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.
> > 
> > []
> > > Where's the removal of pr_warning so we don't have more sneak in?
> > 
> > After all of these actually get applied,
> > and maybe a cycle or two later, one would
> > get sent.
> > 
> 
> By which point you'll get a few reincarnation of it. So you'll have to
> do the same exercise again :-(

Maybe to one or two files.  Not a big deal.

> I guess the question is - are you expecting to get the series merged
> all together/via one tree ?

No.  The only person that could do that effectively is Linus.

> If not, your plan is perfectly reasonable.



Re: [PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn

2017-02-23 Thread Joe Perches
On Thu, 2017-02-23 at 09:28 -0600, Rob Herring wrote:
> On Fri, Feb 17, 2017 at 1:11 AM, Joe Perches <j...@perches.com> wrote:
> > There are ~4300 uses of pr_warn and ~250 uses of the older
> > pr_warning in the kernel source tree.
> > 
> > Make the use of pr_warn consistent across all kernel files.
> > 
> > This excludes all files in tools/ as there is a separate
> > define pr_warning for that directory tree and pr_warn is
> > not used in tools/.
> > 
> > Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.
[]
> Where's the removal of pr_warning so we don't have more sneak in?

After all of these actually get applied,
and maybe a cycle or two later, one would
get sent.



[PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn

2017-02-16 Thread Joe Perches
There are ~4300 uses of pr_warn and ~250 uses of the older
pr_warning in the kernel source tree.

Make the use of pr_warn consistent across all kernel files.

This excludes all files in tools/ as there is a separate
define pr_warning for that directory tree and pr_warn is
not used in tools/.

Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.

Miscellanea:

o Coalesce formats and realign arguments

Some files not compiled - no cross-compilers

Joe Perches (35):
  alpha: Convert remaining uses of pr_warning to pr_warn
  ARM: ep93xx: Convert remaining uses of pr_warning to pr_warn
  arm64: Convert remaining uses of pr_warning to pr_warn
  arch/blackfin: Convert remaining uses of pr_warning to pr_warn
  ia64: Convert remaining use of pr_warning to pr_warn
  powerpc: Convert remaining uses of pr_warning to pr_warn
  sh: Convert remaining uses of pr_warning to pr_warn
  sparc: Convert remaining use of pr_warning to pr_warn
  x86: Convert remaining uses of pr_warning to pr_warn
  drivers/acpi: Convert remaining uses of pr_warning to pr_warn
  block/drbd: Convert remaining uses of pr_warning to pr_warn
  gdrom: Convert remaining uses of pr_warning to pr_warn
  drivers/char: Convert remaining use of pr_warning to pr_warn
  clocksource: Convert remaining use of pr_warning to pr_warn
  drivers/crypto: Convert remaining uses of pr_warning to pr_warn
  fmc: Convert remaining use of pr_warning to pr_warn
  drivers/gpu: Convert remaining uses of pr_warning to pr_warn
  drivers/ide: Convert remaining uses of pr_warning to pr_warn
  drivers/input: Convert remaining uses of pr_warning to pr_warn
  drivers/isdn: Convert remaining uses of pr_warning to pr_warn
  drivers/macintosh: Convert remaining uses of pr_warning to pr_warn
  drivers/media: Convert remaining use of pr_warning to pr_warn
  drivers/mfd: Convert remaining uses of pr_warning to pr_warn
  drivers/mtd: Convert remaining uses of pr_warning to pr_warn
  drivers/of: Convert remaining uses of pr_warning to pr_warn
  drivers/oprofile: Convert remaining uses of pr_warning to pr_warn
  drivers/platform: Convert remaining uses of pr_warning to pr_warn
  drivers/rapidio: Convert remaining use of pr_warning to pr_warn
  drivers/scsi: Convert remaining use of pr_warning to pr_warn
  drivers/sh: Convert remaining use of pr_warning to pr_warn
  drivers/tty: Convert remaining uses of pr_warning to pr_warn
  drivers/video: Convert remaining uses of pr_warning to pr_warn
  kernel/trace: Convert remaining uses of pr_warning to pr_warn
  lib: Convert remaining uses of pr_warning to pr_warn
  sound/soc: Convert remaining uses of pr_warning to pr_warn

 arch/alpha/kernel/perf_event.c |  4 +-
 arch/arm/mach-ep93xx/core.c|  4 +-
 arch/arm64/include/asm/syscall.h   |  8 ++--
 arch/arm64/kernel/hw_breakpoint.c  |  8 ++--
 arch/arm64/kernel/smp.c|  4 +-
 arch/blackfin/kernel/nmi.c |  2 +-
 arch/blackfin/kernel/ptrace.c  |  2 +-
 arch/blackfin/mach-bf533/boards/stamp.c|  2 +-
 arch/blackfin/mach-bf537/boards/cm_bf537e.c|  2 +-
 arch/blackfin/mach-bf537/boards/cm_bf537u.c|  2 +-
 arch/blackfin/mach-bf537/boards/stamp.c|  2 +-
 arch/blackfin/mach-bf537/boards/tcm_bf537.c|  2 +-
 arch/blackfin/mach-bf561/boards/cm_bf561.c |  2 +-
 arch/blackfin/mach-bf561/boards/ezkit.c|  2 +-
 arch/blackfin/mm/isram-driver.c|  4 +-
 arch/ia64/kernel/setup.c   |  6 +--
 arch/powerpc/kernel/pci-common.c   |  4 +-
 arch/powerpc/mm/init_64.c  |  5 +--
 arch/powerpc/mm/mem.c  |  3 +-
 arch/powerpc/platforms/512x/mpc512x_shared.c   |  4 +-
 arch/powerpc/platforms/85xx/socrates_fpga_pic.c|  7 ++--
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |  2 +-
 arch/powerpc/platforms/pasemi/dma_lib.c|  4 +-
 arch/powerpc/platforms/powernv/opal.c  |  8 ++--
 arch/powerpc/platforms/powernv/pci-ioda.c  | 10 ++---
 arch/powerpc/platforms/ps3/device-init.c   | 14 +++
 arch/powerpc/platforms/ps3/mm.c|  4 +-
 arch/powerpc/platforms/ps3/os-area.c   |  2 +-
 arch/powerpc/platforms/pseries/iommu.c |  8 ++--
 arch/powerpc/platforms/pseries/setup.c |  4 +-
 arch/powerpc/sysdev/fsl_pci.c  |  9 ++---
 arch/powerpc/sysdev/mpic.c | 10 ++---
 arch/powerpc/sysdev/xics/icp-native.c  | 10 ++---
 arch/powerpc/sysdev/xics/ics-opal.c|  4 +-
 arch/powerpc/sysdev/xics/ics-rtas.c|  4 +-
 arch/powerpc/sysdev/xics/xics-common.c |  8 ++--
 arch/sh/boards/mach-sdk7786/nmi.c  |  2 +-
 arch/sh/drivers/pci/fixups-sdk7786.c   |  2 +-
 arch/sh/kernel/io_trapped.c

[PATCH 15/35] drivers/crypto: Convert remaining uses of pr_warning to pr_warn

2017-02-16 Thread Joe Perches
To enable eventual removal of pr_warning

This makes pr_warn use consistent for drivers/crypto

Prior to this patch, there were 3 uses of pr_warning and
12 uses of pr_warn in drivers/crypto

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/crypto/n2_core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c
index c5aac25a5738..82ab91adfee7 100644
--- a/drivers/crypto/n2_core.c
+++ b/drivers/crypto/n2_core.c
@@ -365,8 +365,8 @@ static int n2_hash_cra_init(struct crypto_tfm *tfm)
fallback_tfm = crypto_alloc_ahash(fallback_driver_name, 0,
  CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback_tfm)) {
-   pr_warning("Fallback driver '%s' could not be loaded!\n",
-  fallback_driver_name);
+   pr_warn("Fallback driver '%s' could not be loaded!\n",
+   fallback_driver_name);
err = PTR_ERR(fallback_tfm);
goto out;
}
@@ -402,16 +402,16 @@ static int n2_hmac_cra_init(struct crypto_tfm *tfm)
fallback_tfm = crypto_alloc_ahash(fallback_driver_name, 0,
  CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback_tfm)) {
-   pr_warning("Fallback driver '%s' could not be loaded!\n",
-  fallback_driver_name);
+   pr_warn("Fallback driver '%s' could not be loaded!\n",
+   fallback_driver_name);
err = PTR_ERR(fallback_tfm);
goto out;
}
 
child_shash = crypto_alloc_shash(n2alg->child_alg, 0, 0);
if (IS_ERR(child_shash)) {
-   pr_warning("Child shash '%s' could not be loaded!\n",
-  n2alg->child_alg);
+   pr_warn("Child shash '%s' could not be loaded!\n",
+   n2alg->child_alg);
err = PTR_ERR(child_shash);
goto out_free_fallback;
}
-- 
2.10.0.rc2.1.g053435c



Re: [PATCH] crypto: cmac - fix alignment of 'consts'

2016-10-10 Thread Joe Perches
On Mon, 2016-10-10 at 10:37 -0700, Eric Biggers wrote:
> On Mon, Oct 10, 2016 at 10:29:55AM -0700, Joe Perches wrote:
> > On Mon, 2016-10-10 at 10:15 -0700, Eric Biggers wrote:
> > > The per-transform 'consts' array is accessed as __be64 in
> > > crypto_cmac_digest_setkey() but was only guaranteed to be aligned to
> > > __alignof__(long).  Fix this by aligning it to __alignof__(__be64).
> > []
> > > diff --git a/crypto/cmac.c b/crypto/cmac.c
> > []
> > > @@ -57,7 +57,8 @@ static int crypto_cmac_digest_setkey(struct 
> > > crypto_shash *parent,
> > >   unsigned long alignmask = crypto_shash_alignmask(parent);
> > >   struct cmac_tfm_ctx *ctx = crypto_shash_ctx(parent);
> > >   unsigned int bs = crypto_shash_blocksize(parent);
> > > - __be64 *consts = PTR_ALIGN((void *)ctx->ctx, alignmask + 1);
> > > + __be64 *consts = PTR_ALIGN((void *)ctx->ctx,
> > > +(alignmask | (__alignof__(__be64) - 1)) + 1);
> > 
> > 
> > Using a bitwise or looks very odd there.  Perhaps:
> > 
> > min(alignmask + 1, __alignof__(__be64))
> > 
> 
> 
> Alignment has to be a power of 2.  From the code I've read, crypto drivers 
> work
> with alignment a lot and use bitwise OR to mean "the more restrictive of these
> alignmasks".  So I believe the way it's written is the preferred style.
> 
> Eric

Hey Eric.

I don't see any PTR_ALIGN uses in crypto/ or drivers/crypto/ that
use a bitwise or, just mask + 1, but I believe the effect is the
same.  Anyway, your choice, but I think using min is clearer.

cheers, Joe
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: cmac - fix alignment of 'consts'

2016-10-10 Thread Joe Perches
On Mon, 2016-10-10 at 10:15 -0700, Eric Biggers wrote:
> The per-transform 'consts' array is accessed as __be64 in
> crypto_cmac_digest_setkey() but was only guaranteed to be aligned to
> __alignof__(long).  Fix this by aligning it to __alignof__(__be64).
[]
> diff --git a/crypto/cmac.c b/crypto/cmac.c
[]
> @@ -57,7 +57,8 @@ static int crypto_cmac_digest_setkey(struct crypto_shash 
> *parent,
>   unsigned long alignmask = crypto_shash_alignmask(parent);
>   struct cmac_tfm_ctx *ctx = crypto_shash_ctx(parent);
>   unsigned int bs = crypto_shash_blocksize(parent);
> - __be64 *consts = PTR_ALIGN((void *)ctx->ctx, alignmask + 1);
> + __be64 *consts = PTR_ALIGN((void *)ctx->ctx,
> +(alignmask | (__alignof__(__be64) - 1)) + 1);

Using a bitwise or looks very odd there.  Perhaps:

min(alignmask + 1, __alignof__(__be64))

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: squash lines for simple wrapper functions

2016-09-13 Thread Joe Perches
On Wed, 2016-09-14 at 11:10 +0900, Masahiro Yamada wrote:
> 2016-09-13 4:44 GMT+09:00 Joe Perches <j...@perches.com>:
> > On Tue, 2016-09-13 at 04:27 +0900, Masahiro Yamada wrote:
> > > Remove unneeded variables and assignments.
> > Was this found by visual inspection or some tool?
> > If it's via a tool, it's good to mention that in the changelog.
> I used Coccinelle, but I did not mention it
> in case somebody may say "then, please provide your semantic patch".
> As a Coccinelle beginner, I do not want to expose my stupid semantic patch.

If you get it "exposed", you'd likely learn something from others
that would give a few suggestions/tips on how to improve it.


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] chcr: Support for Chelsio's Crypto Hardware

2016-07-11 Thread Joe Perches
On Mon, 2016-07-11 at 11:28 -0700, Yeshaswi M R Gowda wrote:
> The Chelsio's Crypto Hardware can perform the following operations:
> SHA1, SHA224, SHA256, SHA384 and SHA512, HMAC(SHA1), HMAC(SHA224),
> HMAC(SHA256), HMAC(SHA384), HAMC(SHA512), AES-128-CBC, AES-192-CBC,
> AES-256-CBC, AES-128-XTS, AES-256-XTS
> 
> This patch implements the driver for above mentioned features.

trivial notes:

> diff --git a/drivers/crypto/chelsio/chcr_algo.c 
> b/drivers/crypto/chelsio/chcr_algo.c
[]
> +int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
> +  int error_status)
> +{
[]
> + case CRYPTO_ALG_TYPE_BLKCIPHER:
> + ctx_req.req.ablk_req = (struct ablkcipher_request *)req;
> + ctx_req.ctx.ablk_ctx =
> + ablkcipher_request_ctx(ctx_req.req.ablk_req);
> + if (error_status)
> + goto dma_unmap_blkcipher;
> + fw6_pld = (struct cpl_fw6_pld *)input;
> + memcpy(ctx_req.req.ablk_req->info, _pld->data[2],
> +    AES_BLOCK_SIZE);
> +dma_unmap_blkcipher:
> + dma_unmap_sg(_ctx->lldi.pdev->dev, ctx_req.req.ablk_req->dst,
> +  ABLK_CTX(ctx)->dst_nents, DMA_FROM_DEVICE);
> + if (ctx_req.ctx.ablk_ctx->skb) {
> + kfree_skb(ctx_req.ctx.ablk_ctx->skb);
> + ctx_req.ctx.ablk_ctx->skb = NULL;
> + }
> + break;

This case label is only used here right?

This would be better without the goto

[]

> + if (IS_ERR(base_hash)) {
> + pr_err("Can not allocate sha-generic algo.\n");
> + return (void *)base_hash;
> + }

Please add
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include to prefix any pr_ uses.

[]
> +/*
> + *   chcr_register_alg - Register crypto algorithms with kernel framework.
> + */
> +static int chcr_register_alg(void)
> +{
> + struct crypto_alg ai;
> + int err = 0, i;
> + char *name = NULL;
> +
> + for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
> + if (driver_algs[i].is_registered)
> + continue;
> + switch (driver_algs[i].type & CRYPTO_ALG_TYPE_MASK) {
> + case CRYPTO_ALG_TYPE_ABLKCIPHER:
> + err = crypto_register_alg(_algs[i].alg.crypto);
> + name = driver_algs[i].alg.crypto.cra_driver_name;
> + break;
> + case CRYPTO_ALG_TYPE_AHASH:

This could be clearer with a temporary for
driver_algs[i].alg.hash

 hash = _algs[i].alg.hash;

> + driver_algs[i].alg.hash.update = chcr_ahash_update;

hash->update = chcr_ahash_update;
etc...

> + driver_algs[i].alg.hash.final = chcr_ahash_final;
> + driver_algs[i].alg.hash.finup = chcr_ahash_finup;
> + driver_algs[i].alg.hash.digest = chcr_ahash_digest;
> + driver_algs[i].alg.hash.export = chcr_ahash_export;
> + driver_algs[i].alg.hash.import = chcr_ahash_import;
> + driver_algs[i].alg.hash.halg.statesize =
> + sizeof(struct chcr_ahash_req_ctx);

Even with this sort of change, a lot of barely >80 column lines
are split making the code a bit less readable.

It might be better to avoid splitting these long lines and
ignore the >80 column limits occasionally.

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] crypto: sha256-mb - cleanup a || vs | typo

2016-06-30 Thread Joe Perches
On Thu, 2016-06-30 at 10:50 +0300, Dan Carpenter wrote:
> On Wed, Jun 29, 2016 at 10:05:53AM -0700, H. Peter Anvin wrote:
> > On 06/29/16 07:42, Dan Carpenter wrote:
> > > > > and | behave basically the same here but || is intended.  It causes a
> > > static checker warning to mix up bitwise and logical operations.
> > > 
> > > Signed-off-by: Dan Carpenter 
> > > 
> > > diff --git a/arch/x86/crypto/sha256-mb/sha256_mb.c 
> > > b/arch/x86/crypto/sha256-mb/sha256_mb.c
[]
> > > @@ -299,7 +299,7 @@ static struct sha256_hash_ctx 
> > > *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
> > >    * Or if the user's buffer contains less than a whole block,
> > >    * append as much as possible to the extra block.
> > >    */
> > > - if ((ctx->partial_block_buffer_length) | (len < SHA256_BLOCK_SIZE)) {
> > > + if ((ctx->partial_block_buffer_length) || (len < SHA256_BLOCK_SIZE)) {
> > >   /* Compute how many bytes to copy from user buffer into
> > >    * extra block
> > >    */
> > > 
> > As far as I know the | was an intentional optimization, so you may way
> > to look at the generated code.
> I know how the rules work.  I just thought it looked more like a typo
> than an optimization.  It's normally a typo.  It's hard to tell the
> intent.

The compiler could potentially emit the same code when
optimizing but at least gcc 5.3 doesn't.

It's probably useful to add a comment for the specific intent
here rather than change a potentially useful static checker.

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/6] crypto: Linux Random Number Generator

2016-04-24 Thread Joe Perches
On Sun, 2016-04-24 at 12:40 +0200, Stephan Mueller wrote:
> The LRNG with all its properties is documented in [1]. This
> documentation covers the functional discussion as well as testing of all
> aspects of entropy processing. In addition, the documentation explains
> the conducted regression tests to verify that the LRNG is API and ABI
> compatible with the legacy /dev/random implementation.
> 
> [1] http://www.chronox.de/lrng.html

Thanks.

Links get stale.

It may be better to put an ascii version of the pdf
in Documentation/ and the test code in tools/

and some trivial notes:

> diff --git a/crypto/lrng.c b/crypto/lrng.c
[]
> +/* debug macro */
> +#define DRIVER_NAME "lrng"

Using
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include would be a lot more common.

> +#if 0
> +#define dbg(fmt, ...) pr_info(DRIVER_NAME": " fmt, ##__VA_ARGS__)
> +#else
> +#define dbg(fmt, ...)
> +#endif

pr_debug or is there some interaction with
dynamic_debug you want to avoid?

And it's generally better to use something like

#if 0
#define dbg(fmt, ...) pr_info(fmt, ##__VA_ARGS__)
#else
#define dbg(fmt, ...) no_printk(fmt, ##__VA_ARGS__)

so that new dbg statements would not have
format/argument mismatches and argument
evaluation side-effects are still eliminated.

> +static void lrng_pdrbg_init_ops(u32 entropy_bits)
> +{
> + if (lrng_pdrbg.pdrbg_fully_seeded)
> + return;
> +
> + BUILD_BUG_ON(LRNG_IRQ_MIN_NUM % LRNG_POOL_WORD_BITS);
> + BUILD_BUG_ON((LRNG_MIN_SEED_ENTROPY_BITS * LRNG_IRQ_ENTROPY_BITS /
> +  LRNG_DRBG_SECURITY_STRENGTH_BITS) > LRNG_IRQ_MIN_NUM);
> +
> + /* DRBG is seeded with full security strength */
> + if (entropy_bits >= LRNG_DRBG_SECURITY_STRENGTH_BITS) {
> + lrng_pdrbg.pdrbg_fully_seeded = true;
> + lrng_pdrbg.pdrbg_min_seeded = true;
> + pr_info(DRIVER_NAME": primary DRBG fully seeded\n");

Using pr_fmt eliminates the need for these
DRIVER_NAME ": " prefix inclusions in the format
> +static int __init lrng_init(void)
> +{
[]
> + pr_info(DRIVER_NAME": deactivating initial RNG - %d bytes delivered",
> + atomic_read(_initrng_bytes));

Should use \n to terminate the format.

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/4] MAINTAINERS: Add myself as maintainer of Allwinner Security System

2015-03-16 Thread Joe Perches
On Mon, 2015-03-16 at 20:01 +0100, LABBE Corentin wrote:
[]
 diff --git a/MAINTAINERS b/MAINTAINERS
[]
 @@ -10923,6 +10923,12 @@ L:   linux...@kvack.org
  S:   Maintained
  F:   mm/zswap.c
  
 +ALLWINNER SECURITY SYSTEM
 +M:   Corentin Labbe clabbe.montj...@gmail.com
 +L:   linux-crypto@vger.kernel.org
 +S:   Maintained
 +F:   drivers/crypto/sunxi-ss/

Use alphabetic ordering for new sections please.

Please place this section between:

ALI1563 I2C DRIVER
and
ALPHA PORT


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 4/4] crypto: Add Allwinner Security System crypto accelerator

2014-10-20 Thread Joe Perches
On Tue, 2014-10-21 at 02:28 +0300, Vladimir Zapolskiy wrote:
 On 19.10.2014 17:16, LABBE Corentin wrote:
  Add support for the Security System included in Allwinner SoC A20.
  The Security System is a hardware cryptographic accelerator that support 
  AES/MD5/SHA1/DES/3DES/PRNG algorithms.
[]
  diff --git a/drivers/crypto/sunxi-ss/sunxi-ss-core.c 
  b/drivers/crypto/sunxi-ss/sunxi-ss-core.c
[]
  +   cr = clk_get_rate(ss-busclk);
  +   if (cr = cr_ahb)
  +   dev_dbg(pdev-dev, Clock bus %lu (%lu MHz) (must be = 
  %lu)\n,
  +   cr, cr / 100, cr_ahb);
  +   else
  +   dev_warn(pdev-dev, Clock bus %lu (%lu MHz) (must be = 
  %lu)\n,
  +   cr, cr / 100, cr_ahb);
 
 See next comment.
 
  +   cr = clk_get_rate(ss-ssclk);
  +   if (cr = cr_mod)
  +   if (cr  cr_mod)
  +   dev_info(pdev-dev, Clock ss %lu (%lu MHz) (must be 
  = %lu)\n,
  +   cr, cr / 100, cr_mod);
  +   else
  +   dev_dbg(pdev-dev, Clock ss %lu (%lu MHz) (must be = 
  %lu)\n,
  +   cr, cr / 100, cr_mod);
  +   else
  +   dev_warn(pdev-dev, Clock ss is at %lu (%lu MHz) (must be = 
  %lu)\n,
  +   cr, cr / 100, cr_mod);
 
 The management of kernel log levels looks pretty strange. As far as I
 understand there is no error on any clock rate, I'd recommend to keep
 only one information message.

And if not, please add some braces.

 hash_init: initialize request context */
  +int sunxi_hash_init(struct ahash_request *areq)
  +{
  +   const char *hash_type;
  +   struct sunxi_req_ctx *op = ahash_request_ctx(areq);
  +
  +   memset(op, 0, sizeof(struct sunxi_req_ctx));
  +
  +   hash_type = crypto_tfm_alg_name(areq-base.tfm);
  +
  +   if (strcmp(hash_type, sha1) == 0)
  +   op-mode = SS_OP_SHA1;
  +   if (strcmp(hash_type, md5) == 0)
  +   op-mode = SS_OP_MD5;

else if ?

  +   if (op-mode == 0)
  +   return -EINVAL;

maybe this?

if (!strcmp(hash_type, sha1))
op-mode = SS_OP_SHA1;
else if (!strcmp(hash_type, md5))
op-mode = SH_OP_MD5;
else
return -EINVAL;

  +
  +   return 0;
  +}
[]
  +int sunxi_hash_update(struct ahash_request *areq)
  +{
[]
  +   dev_dbg(ss-dev, %s %s bc=%llu len=%u mode=%x bw=%u ww=%u,
  +   __func__, crypto_tfm_alg_name(areq-base.tfm),
  +   op-byte_count, areq-nbytes, op-mode,
  +   op-nbw, op-nwait);

dev_dbg statements generally don't need __func__ as
dynamic_debug can add it.

If you want to keep it, the most common output form for
__func__ is '%s: ..., __func__'

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Crypto: gf128mul : fixed a parentheses coding style issue

2014-10-13 Thread Joe Perches
On Mon, 2014-10-13 at 21:12 +0100, Michael Roocroft wrote:
 On 10/13/14 00:01, Joe Perches wrote:
  On Sun, 2014-10-12 at 21:49 +0100, Mike Roocroft wrote:
  Fixed a coding style issue.
  []
  diff --git a/crypto/gf128mul.c b/crypto/gf128mul.c
  []
  @@ -97,7 +97,7 @@
the table above
*/

  -#define xx(p, q)  0x##p##q
  +#define xx(p, q)  (0x##p##q)

#define xda_bbe(i) ( \
 (i  0x80 ? xx(43, 80) : 0) ^ (i  0x40 ? xx(21, c0) : 0) ^ \
  I think that macro is pretty useless and nothing
  but obfuscation now.
 
  The comment above it doesn't seem useful either.
 
  How about just removing and replacing the uses
  like this?
 
  ---
crypto/gf128mul.c | 27 ---
1 file changed, 8 insertions(+), 19 deletions(-)
 
  diff --git a/crypto/gf128mul.c b/crypto/gf128mul.c
  index 5276607..90cf17d 100644
  --- a/crypto/gf128mul.c
  +++ b/crypto/gf128mul.c
  @@ -88,29 +88,18 @@
  q(0xf8), q(0xf9), q(0xfa), q(0xfb), q(0xfc), q(0xfd), q(0xfe), q(0xff) \
}

  -/* Given the value i in 0..255 as the byte overflow when a field element
  -in GHASH is multiplied by x^8, this function will return the values 
  that
  -are generated in the lo 16-bit word of the field value by applying the
  -modular polynomial. The values lo_byte and hi_byte are returned via the
  -macro xp_fun(lo_byte, hi_byte) so that the values can be assembled into
  -memory as required by a suitable definition of this macro operating on
  -the table above
  -*/
  -
  -#define xx(p, q)   0x##p##q
  -
#define xda_bbe(i) ( \
  -   (i  0x80 ? xx(43, 80) : 0) ^ (i  0x40 ? xx(21, c0) : 0) ^ \
  -   (i  0x20 ? xx(10, e0) : 0) ^ (i  0x10 ? xx(08, 70) : 0) ^ \
  -   (i  0x08 ? xx(04, 38) : 0) ^ (i  0x04 ? xx(02, 1c) : 0) ^ \
  -   (i  0x02 ? xx(01, 0e) : 0) ^ (i  0x01 ? xx(00, 87) : 0) \
  +   (i  0x80 ? 0x4380 : 0) ^ (i  0x40 ? 0x21c0 : 0) ^ \
  +   (i  0x20 ? 0x10e0 : 0) ^ (i  0x10 ? 0x0870 : 0) ^ \
  +   (i  0x08 ? 0x0438 : 0) ^ (i  0x04 ? 0x021c : 0) ^ \
  +   (i  0x02 ? 0x010e : 0) ^ (i  0x01 ? 0x0087 : 0) \
)

#define xda_lle(i) ( \
  -   (i  0x80 ? xx(e1, 00) : 0) ^ (i  0x40 ? xx(70, 80) : 0) ^ \
  -   (i  0x20 ? xx(38, 40) : 0) ^ (i  0x10 ? xx(1c, 20) : 0) ^ \
  -   (i  0x08 ? xx(0e, 10) : 0) ^ (i  0x04 ? xx(07, 08) : 0) ^ \
  -   (i  0x02 ? xx(03, 84) : 0) ^ (i  0x01 ? xx(01, c2) : 0) \
  +   (i  0x80 ? 0xe100 : 0) ^ (i  0x40 ? 0x7080 : 0) ^ \
  +   (i  0x20 ? 0x3840 : 0) ^ (i  0x10 ? 0x1c20 : 0) ^ \
  +   (i  0x08 ? 0x0e10 : 0) ^ (i  0x04 ? 0x0708 : 0) ^ \
  +   (i  0x02 ? 0x0384 : 0) ^ (i  0x01 ? 0x01c2 : 0) \
)

static const u16 gf128mul_table_lle[256] = gf128mul_dat(xda_lle);
 
 
 
 Hi there,

Hi Mike.

 I'm not really contributing anything other than getting code checkpatch 
 clean, whilst
 I relearn C and get a feel for various parts of the kernel.

checkpatch cleanliness, while OK for some parts of the
kernel, should not be an end-goal.

checkpatch is really a tool to check patches.

If you want to submit neatening only patches, please
do your changes in drivers/staging/

Otherwise, please look for code that isn't simply a
style neatening bit, but something that actively makes
reading the code easier, makes the object code smaller
or faster, reduces complexity, adds extensibility,
etc, etc...

cheers, Joe



--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Crypto: gf128mul : fixed a parentheses coding style issue

2014-10-13 Thread Joe Perches
On Mon, 2014-10-13 at 21:52 +0100, Michael Roocroft wrote:
 I fully intend to making more meaningful contributions
 when my confidence in writing C is better than it is at the moment. I'll 
 concentrate
 on making any changes to staging whilst I learn and get to grips with git, and
 continue to look through the rest of the kernel tree as a learning exercise.

Sounds like a good plan to me.  welcome btw.

 by looking and not doing anything i'll never learn anything.

True words... 

cheers, Joe

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Crypto: gf128mul : fixed a parentheses coding style issue

2014-10-12 Thread Joe Perches
On Sun, 2014-10-12 at 21:49 +0100, Mike Roocroft wrote:
 Fixed a coding style issue.
[]
 diff --git a/crypto/gf128mul.c b/crypto/gf128mul.c
[]
 @@ -97,7 +97,7 @@
  the table above
  */
  
 -#define xx(p, q) 0x##p##q
 +#define xx(p, q) (0x##p##q)
  
  #define xda_bbe(i) ( \
   (i  0x80 ? xx(43, 80) : 0) ^ (i  0x40 ? xx(21, c0) : 0) ^ \

I think that macro is pretty useless and nothing
but obfuscation now.

The comment above it doesn't seem useful either.

How about just removing and replacing the uses
like this?

---
 crypto/gf128mul.c | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/crypto/gf128mul.c b/crypto/gf128mul.c
index 5276607..90cf17d 100644
--- a/crypto/gf128mul.c
+++ b/crypto/gf128mul.c
@@ -88,29 +88,18 @@
q(0xf8), q(0xf9), q(0xfa), q(0xfb), q(0xfc), q(0xfd), q(0xfe), q(0xff) \
 }
 
-/* Given the value i in 0..255 as the byte overflow when a field element
-in GHASH is multiplied by x^8, this function will return the values that
-are generated in the lo 16-bit word of the field value by applying the
-modular polynomial. The values lo_byte and hi_byte are returned via the
-macro xp_fun(lo_byte, hi_byte) so that the values can be assembled into
-memory as required by a suitable definition of this macro operating on
-the table above
-*/
-
-#define xx(p, q)   0x##p##q
-
 #define xda_bbe(i) ( \
-   (i  0x80 ? xx(43, 80) : 0) ^ (i  0x40 ? xx(21, c0) : 0) ^ \
-   (i  0x20 ? xx(10, e0) : 0) ^ (i  0x10 ? xx(08, 70) : 0) ^ \
-   (i  0x08 ? xx(04, 38) : 0) ^ (i  0x04 ? xx(02, 1c) : 0) ^ \
-   (i  0x02 ? xx(01, 0e) : 0) ^ (i  0x01 ? xx(00, 87) : 0) \
+   (i  0x80 ? 0x4380 : 0) ^ (i  0x40 ? 0x21c0 : 0) ^ \
+   (i  0x20 ? 0x10e0 : 0) ^ (i  0x10 ? 0x0870 : 0) ^ \
+   (i  0x08 ? 0x0438 : 0) ^ (i  0x04 ? 0x021c : 0) ^ \
+   (i  0x02 ? 0x010e : 0) ^ (i  0x01 ? 0x0087 : 0) \
 )
 
 #define xda_lle(i) ( \
-   (i  0x80 ? xx(e1, 00) : 0) ^ (i  0x40 ? xx(70, 80) : 0) ^ \
-   (i  0x20 ? xx(38, 40) : 0) ^ (i  0x10 ? xx(1c, 20) : 0) ^ \
-   (i  0x08 ? xx(0e, 10) : 0) ^ (i  0x04 ? xx(07, 08) : 0) ^ \
-   (i  0x02 ? xx(03, 84) : 0) ^ (i  0x01 ? xx(01, c2) : 0) \
+   (i  0x80 ? 0xe100 : 0) ^ (i  0x40 ? 0x7080 : 0) ^ \
+   (i  0x20 ? 0x3840 : 0) ^ (i  0x10 ? 0x1c20 : 0) ^ \
+   (i  0x08 ? 0x0e10 : 0) ^ (i  0x04 ? 0x0708 : 0) ^ \
+   (i  0x02 ? 0x0384 : 0) ^ (i  0x01 ? 0x01c2 : 0) \
 )
 
 static const u16 gf128mul_table_lle[256] = gf128mul_dat(xda_lle);


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use

2014-07-18 Thread Joe Perches
On Fri, 2014-07-18 at 09:43 -0700, Greg KH wrote:
 On Fri, Jul 18, 2014 at 12:22:13PM -0400, John W. Linville wrote:
  On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
   We should prefer `const struct pci_device_id` over
   `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
   This issue was reported by checkpatch.
   scripts/checkpatch.pl | 4 ++--
  Honestly, I prefer the macro -- it stands-out more.  Maybe the style
  guidelines and/or checkpatch should change instead?
 
 The macro is horrid, no other bus has this type of thing just to save a
 few characters in typing, so why should PCI be special in this regard
 anymore?

I think it doesn't matter much.

The PCI_DEVICE and PCI_VDEVICE macro uses are somewhat similar
and are frequently used with PCI_DEVICE_TABLE, so there's some
commonality there.

The checkpatch message could be made --strict/CHK instead of
WARN so most people would never see it.

Of course it could be removed altogether too.  I don't care.
---
(suggested patch is for -next)

 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dc72a9b..754fbf2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3018,8 +3018,8 @@ sub process {
 
 # check for uses of DEFINE_PCI_DEVICE_TABLE
if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) 
{
-   if (WARN(DEFINE_PCI_DEVICE_TABLE,
-Prefer struct pci_device_id over deprecated 
DEFINE_PCI_DEVICE_TABLE\n . $herecurr) 
+   if (CHK(DEFINE_PCI_DEVICE_TABLE,
+   Prefer struct pci_device_id over deprecated 
DEFINE_PCI_DEVICE_TABLE\n . $herecurr) 
$fix) {
$fixed[$fixlinenr] =~ 
s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const 
struct pci_device_id $1\[\] = /;
}


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 1/5] seq_file: provide an analogue of print_hex_dump()

2014-07-10 Thread Joe Perches
On Thu, 2014-07-10 at 12:50 +0300, Andy Shevchenko wrote:
 I have considered to modify hex_dump_to_buffer() to return how many
 bytes it actually proceed to the buffer. In that case we can directly
 print to m-buf like other seq_foo calls do.
 
 But I still have doubts about it. Any opinion?

Simpler is better.


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 4/5] parisc: use seq_hex_dump() to dump buffers

2014-07-09 Thread Joe Perches
On Wed, 2014-07-09 at 18:24 +0300, Andy Shevchenko wrote:
 Instead of custom approach let's use recently introduced seq_hex_dump() 
 helper.

Doesn't this also change the output from
   
to
          


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 0/5] fs/seq_file: introduce seq_hex_dump() helper

2014-07-09 Thread Joe Perches
On Wed, 2014-07-09 at 18:24 +0300, Andy Shevchenko wrote:
 This introduces a new helper and switches current users to use it.

While seq_print_hex_dump seems useful, I'm not sure
existing forms can be changed to use it if any output
content changes.

seq_ is supposed to be a stable API.


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 1/5] seq_file: provide an analogue of print_hex_dump()

2014-07-09 Thread Joe Perches
On Wed, 2014-07-09 at 22:39 +0200, Marek Vasut wrote:
 The above function looks like almost verbatim copy of print_hex_dump(). The 
 only 
 difference I can spot is that it's calling seq_printf() instead of printk(). 
 Can 
 you not instead generalize print_hex_dump() and based on it's invocation, 
 make 
 it call either seq_printf() or printk() ?

How do you propose doing that given any seq_foo call
requires a struct seq_file * and print_hex_dump needs
a KERN_LEVEL.

Is there an actual value to it?



--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] DRBG: Fix format string for debugging statements

2014-07-04 Thread Joe Perches
On Fri, 2014-07-04 at 14:21 +0300, Dan Carpenter wrote:
 On Sat, Jun 28, 2014 at 08:53:19PM -0700, Joe Perches wrote:
  On Sun, 2014-06-29 at 05:46 +0200, Stephan Mueller wrote:
   Am Sonntag, 29. Juni 2014, 12:24:02 schrieb Stephen Rothwell:
   
   Hi Stephen,
   
Hi Stephan,

On Sat, 28 Jun 2014 22:01:46 +0200 Stephan Mueller 
smuel...@chronox.de 
   wrote:
 @@ -1987,8 +1987,9 @@ static int __init drbg_init(void)
 
   if (ARRAY_SIZE(drbg_cores) * 2  ARRAY_SIZE(drbg_algs)) {
   
   pr_info(DRBG: Cannot register all DRBG types
 
 - (slots needed: %lu, slots available: %lu)\n,
 - ARRAY_SIZE(drbg_cores) * 2, 
 ARRAY_SIZE(drbg_algs));
 + (slots needed: %u, slots available: %u)\n,
 + (unsigned int)ARRAY_SIZE(drbg_cores) * 2,
 + (unsigned int)ARRAY_SIZE(drbg_algs));

Doesn't ARRAY_SIZE() always return a size_t?  In which case surely we
need no casts, but need to us %zu in the format string.
   
   Unfortunately not at all. On my x86_64, I get the compiler warning that 
   ARRAY_SIZE is a long unsigned int without the cast.

It doesn't seem to for 4.8.
Is there some specific gcc version where this occurs?

  diff --git a/include/linux/kernel.h b/include/linux/kernel.h
[]
  -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + 
  __must_be_array(arr))
  +#define ARRAY_SIZE(arr)\
  +   (sizeof(arr) / sizeof((arr)[0]) + (size_t)__must_be_array(arr))
 
 
 This change is a no-op isn't it?

Yes, it is.  Dumb idea.
Assuming there's some odd promotion, size_t should have been around the
whole thing
#define ARRAY_SIZE(arr) \
((size_t)((sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)))

 I think Stephen Rothwell's suggestion
 is correct.  In linux-next this was changed to %lu which also works...
 
 Are there arches %zu and %lu are different?

I get the same output types and error warnings compiling this
either -m32 or -m64

#include stdio.h
#include stdlib.h

#define typecheck(type, x)  \
({  \
type __dummy;   \
typeof(x) __dummy2; \
(void)(__dummy == __dummy2);  \
1;  \
})

#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))

#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), (a)[0]))
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

int main(int argc, char **argv)
{
char foo[100];
size_t array = sizeof(foo);
typeof (ARRAY_SIZE(foo)) member = ARRAY_SIZE(foo);

int member1 = ARRAY_SIZE(foo);
size_t member2 = ARRAY_SIZE(foo);

typecheck(size_t, member);
typecheck(int, member);

typecheck(size_t, member1);
typecheck(int, member1);

typecheck(size_t, member2);
typecheck(int, member2);

printf(array: %zu, member: %zu\n, array, (int)member);

return 0;
}


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] DRBG: Fix format string for debugging statements

2014-07-04 Thread Joe Perches
On Sat, 2014-07-05 at 01:57 +0200, Stephan Mueller wrote:
 And I also get the same output. Yet I am not sure how that code can be 
 compared to the code in the kernel.

What that code shows is that the ARRAY_SIZE
type is size_t.

The difference is ARRAY_SIZE in the kernel
should be output with %zu.





--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] DRBG: Fix format string for debugging statements

2014-07-04 Thread Joe Perches
On Sat, 2014-07-05 at 02:15 +0200, Stephan Mueller wrote:
 Am Freitag, 4. Juli 2014, 17:09:33 schrieb Joe Perches:
  On Sat, 2014-07-05 at 01:57 +0200, Stephan Mueller wrote:
   And I also get the same output. Yet I am not sure how that code can be
   compared to the code in the kernel.
  
  What that code shows is that the ARRAY_SIZE
  type is size_t.
  
  The difference is ARRAY_SIZE in the kernel
  should be output with %zu.
 
 Using %zu works without a warning on my 64 bit machine. So you are saying 
 that 
 ARRAY_SIZE will always be size_t on every architecture? If yes, I will update 
 my patch.

Hi again.

ARRAY_SIZE is size_t in all architectures.


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] DRBG: Fix format string for debugging statements

2014-06-28 Thread Joe Perches
On Sun, 2014-06-29 at 05:46 +0200, Stephan Mueller wrote:
 Am Sonntag, 29. Juni 2014, 12:24:02 schrieb Stephen Rothwell:
 
 Hi Stephen,
 
  Hi Stephan,
  
  On Sat, 28 Jun 2014 22:01:46 +0200 Stephan Mueller smuel...@chronox.de 
 wrote:
   @@ -1987,8 +1987,9 @@ static int __init drbg_init(void)
   
 if (ARRAY_SIZE(drbg_cores) * 2  ARRAY_SIZE(drbg_algs)) {
 
 pr_info(DRBG: Cannot register all DRBG types
   
   - (slots needed: %lu, slots available: %lu)\n,
   - ARRAY_SIZE(drbg_cores) * 2, ARRAY_SIZE(drbg_algs));
   + (slots needed: %u, slots available: %u)\n,
   + (unsigned int)ARRAY_SIZE(drbg_cores) * 2,
   + (unsigned int)ARRAY_SIZE(drbg_algs));
  
  Doesn't ARRAY_SIZE() always return a size_t?  In which case surely we
  need no casts, but need to us %zu in the format string.
 
 Unfortunately not at all. On my x86_64, I get the compiler warning that 
 ARRAY_SIZE is a long unsigned int without the cast.

This should fix that.
---
 include/linux/kernel.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6e3d497..58bc57d 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -51,7 +51,8 @@
 #define PTR_ALIGN(p, a)((typeof(p))ALIGN((unsigned long)(p), 
(a)))
 #define IS_ALIGNED(x, a)   (((x)  ((typeof(x))(a) - 1)) == 0)
 
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#define ARRAY_SIZE(arr)\
+   (sizeof(arr) / sizeof((arr)[0]) + (size_t)__must_be_array(arr))
 
 /*
  * This looks more complex than it should be. But we need to


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/22] Add and use pci_zalloc_consistent

2014-06-23 Thread Joe Perches
Adding the helper reduces object code size as well as overall
source size line count.

It's also consistent with all the various zalloc mechanisms
in the kernel.

Done with a simple cocci script and some typing.

Joe Perches (22):
  pci-dma-compat: Add pci_zalloc_consistent helper
  atm: Use pci_zalloc_consistent
  block: Use pci_zalloc_consistent
  crypto: Use pci_zalloc_consistent
  infiniband: Use pci_zalloc_consistent
  i810: Use pci_zalloc_consistent
  media: Use pci_zalloc_consistent
  amd: Use pci_zalloc_consistent
  atl1e: Use pci_zalloc_consistent
  enic: Use pci_zalloc_consistent
  sky2: Use pci_zalloc_consistent
  micrel: Use pci_zalloc_consistent
  qlogic: Use pci_zalloc_consistent
  irda: Use pci_zalloc_consistent
  ipw2100: Use pci_zalloc_consistent
  mwl8k: Use pci_zalloc_consistent
  rtl818x: Use pci_zalloc_consistent
  rtlwifi: Use pci_zalloc_consistent
  scsi: Use pci_zalloc_consistent
  staging: Use pci_zalloc_consistent
  synclink_gt: Use pci_zalloc_consistent
  vme: bridges: Use pci_zalloc_consistent

 drivers/atm/he.c   | 31 -
 drivers/atm/idt77252.c | 15 
 drivers/block/DAC960.c | 18 +-
 drivers/block/cciss.c  | 11 +++---
 drivers/block/skd_main.c   | 25 +-
 drivers/crypto/hifn_795x.c |  5 ++-
 drivers/gpu/drm/i810/i810_dma.c|  5 ++-
 drivers/infiniband/hw/amso1100/c2.c|  6 ++--
 drivers/infiniband/hw/nes/nes_hw.c | 12 +++
 drivers/infiniband/hw/nes/nes_verbs.c  |  5 ++-
 drivers/media/common/saa7146/saa7146_core.c| 15 
 drivers/media/common/saa7146/saa7146_fops.c|  5 +--
 drivers/media/pci/bt8xx/bt878.c| 16 +++--
 drivers/media/pci/ngene/ngene-core.c   |  7 ++--
 drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c  | 11 ++
 drivers/media/usb/ttusb-dec/ttusb_dec.c| 11 ++
 drivers/net/ethernet/amd/pcnet32.c | 16 -
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c|  7 ++--
 drivers/net/ethernet/cisco/enic/vnic_dev.c |  8 ++---
 drivers/net/ethernet/marvell/sky2.c|  5 ++-
 drivers/net/ethernet/micrel/ksz884x.c  |  7 ++--
 .../net/ethernet/qlogic/netxen/netxen_nic_ctx.c|  4 +--
 drivers/net/ethernet/qlogic/qlge/qlge_main.c   | 11 +++---
 drivers/net/irda/vlsi_ir.c |  4 +--
 drivers/net/wireless/ipw2x00/ipw2100.c | 16 +++--
 drivers/net/wireless/mwl8k.c   |  6 ++--
 drivers/net/wireless/rtl818x/rtl8180/dev.c | 11 +++---
 drivers/net/wireless/rtlwifi/pci.c | 17 +++--
 drivers/scsi/3w-sas.c  |  5 ++-
 drivers/scsi/a100u2w.c |  8 ++---
 drivers/scsi/be2iscsi/be_main.c| 10 +++---
 drivers/scsi/be2iscsi/be_mgmt.c|  3 +-
 drivers/scsi/csiostor/csio_wr.c|  8 +
 drivers/scsi/eata.c|  5 ++-
 drivers/scsi/hpsa.c|  8 ++---
 drivers/scsi/megaraid/megaraid_mbox.c  | 16 -
 drivers/scsi/megaraid/megaraid_sas_base.c  |  8 ++---
 drivers/scsi/mesh.c|  6 ++--
 drivers/scsi/mvumi.c   |  9 ++---
 drivers/scsi/pm8001/pm8001_sas.c   |  5 ++-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 15 +++-
 drivers/staging/rtl8192ee/pci.c| 37 +++-
 drivers/staging/rtl8821ae/pci.c| 36 +++
 drivers/staging/slicoss/slicoss.c  |  9 ++---
 drivers/staging/vt6655/device_main.c   | 40 +++---
 drivers/tty/synclink_gt.c  |  5 ++-
 drivers/vme/bridges/vme_ca91cx42.c |  6 ++--
 drivers/vme/bridges/vme_tsi148.c   |  6 ++--
 include/asm-generic/pci-dma-compat.h   |  8 +
 49 files changed, 209 insertions(+), 354 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/22] crypto: Use pci_zalloc_consistent

2014-06-23 Thread Joe Perches
Remove the now unnecessary memset too.

Signed-off-by: Joe Perches j...@perches.com
---
 drivers/crypto/hifn_795x.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 12fea3e..8d2a772 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -2617,14 +2617,13 @@ static int hifn_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
}
}
 
-   dev-desc_virt = pci_alloc_consistent(pdev, sizeof(struct hifn_dma),
-   dev-desc_dma);
+   dev-desc_virt = pci_zalloc_consistent(pdev, sizeof(struct hifn_dma),
+  dev-desc_dma);
if (!dev-desc_virt) {
dprintk(Failed to allocate descriptor rings.\n);
err = -ENOMEM;
goto err_out_unmap_bars;
}
-   memset(dev-desc_virt, 0, sizeof(struct hifn_dma));
 
dev-pdev = pdev;
dev-irq = pdev-irq;
-- 
1.8.1.2.459.gbcd45b4.dirty

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/22] Add and use pci_zalloc_consistent

2014-06-23 Thread Joe Perches
On Mon, 2014-06-23 at 10:25 -0700, Luis R. Rodriguez wrote:
 On Mon, Jun 23, 2014 at 06:41:28AM -0700, Joe Perches wrote:
  Adding the helper reduces object code size as well as overall
  source size line count.
  
  It's also consistent with all the various zalloc mechanisms
  in the kernel.
  
  Done with a simple cocci script and some typing.
 
 Awesome, any chance you can paste in the SmPL? Also any chance
 we can get this added to a make coccicheck so that maintainers
 moving forward can use that to ensure that no new code is
 added that uses the old school API?

Not many of these are recent.

Arnd Bergmann reasonably suggested that the pci_alloc_consistent
api be converted the the more widely used dma_alloc_coherent.

https://lkml.org/lkml/2014/6/23/513

 Shouldn't these drivers just use the normal dma-mapping API now?

and I replied:

https://lkml.org/lkml/2014/6/23/525

 Maybe.  I wouldn't mind.
 They do seem to have a trivial bit of unnecessary overhead for 
 hwdev == NULL ? NULL : hwdev-dev

Anyway, here's the little script.
I'm not sure it's worthwhile to add it though.

$ cat ./scripts/coccinelle/api/alloc/pci_zalloc_consistent.cocci
///
/// Use pci_zalloc_consistent rather than
/// pci_alloc_consistent followed by memset with 0
///
/// This considers some simple cases that are common and easy to validate
/// Note in particular that there are no ...s in the rule, so all of the
/// matched code has to be contiguous
///
/// Blatantly cribbed from: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

@@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
@@

- x = (T)pci_alloc_consistent(E1,E2,E3);
+ x = pci_zalloc_consistent(E1,E2,E3);
  if ((x==NULL) || ...) S
- memset((T2)x,0,E2);


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -next 05/26] crypto: Use dma_zalloc_coherent

2014-06-15 Thread Joe Perches
Use the zeroing function instead of dma_alloc_coherent  memset(,0,)

Signed-off-by: Joe Perches j...@perches.com
---
 drivers/crypto/amcc/crypto4xx_core.c | 8 +++-
 drivers/crypto/ixp4xx_crypto.c   | 8 
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/amcc/crypto4xx_core.c 
b/drivers/crypto/amcc/crypto4xx_core.c
index 37f9cc9..d3da537 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -304,14 +304,12 @@ static struct ce_pd *crypto4xx_get_pdp(struct 
crypto4xx_device *dev,
  */
 static u32 crypto4xx_build_gdr(struct crypto4xx_device *dev)
 {
-   dev-gdr = dma_alloc_coherent(dev-core_dev-device,
- sizeof(struct ce_gd) * PPC4XX_NUM_GD,
- dev-gdr_pa, GFP_ATOMIC);
+   dev-gdr = dma_zalloc_coherent(dev-core_dev-device,
+  sizeof(struct ce_gd) * PPC4XX_NUM_GD,
+  dev-gdr_pa, GFP_ATOMIC);
if (!dev-gdr)
return -ENOMEM;
 
-   memset(dev-gdr, 0, sizeof(struct ce_gd) * PPC4XX_NUM_GD);
-
return 0;
 }
 
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index f757a0f..0a32d7c 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -251,12 +251,12 @@ static int setup_crypt_desc(void)
 {
struct device *dev = pdev-dev;
BUILD_BUG_ON(sizeof(struct crypt_ctl) != 64);
-   crypt_virt = dma_alloc_coherent(dev,
-   NPE_QLEN * sizeof(struct crypt_ctl),
-   crypt_phys, GFP_ATOMIC);
+   crypt_virt = dma_zalloc_coherent(dev,
+NPE_QLEN * sizeof(struct crypt_ctl),
+crypt_phys, GFP_ATOMIC);
if (!crypt_virt)
return -ENOMEM;
-   memset(crypt_virt, 0, NPE_QLEN * sizeof(struct crypt_ctl));
+
return 0;
 }
 
-- 
1.8.1.2.459.gbcd45b4.dirty

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -next 00/26] treewide: Use dma_zalloc_coherent

2014-06-15 Thread Joe Perches
Use the zeroing function instead of dma_alloc_coherent  memset(,0,)

Joe Perches (26):
  powerpc: Use dma_zalloc_coherent
  sh: Use dma_zalloc_coherent
  ata: Use dma_zalloc_coherent
  block: Use dma_zalloc_coherent
  crypto: Use dma_zalloc_coherent
  dma: Use dma_zalloc_coherent
  gpu: Use dma_zalloc_coherent
  infiniband: Use dma_zalloc_coherent
  mmc: Use dma_zalloc_coherent
  broadcom: Use dma_zalloc_coherent
  hisilicon: Use dma_zalloc_coherent
  intel: Use dma_zalloc_coherent
  ath: Use dma_zalloc_coherent
  rt2x00: Use dma_zalloc_coherent
  bfa: Use dma_zalloc_coherent
  bnx2fc: Use dma_zalloc_coherent
  bnx2i: Use dma_zalloc_coherent
  dpt_i2o: Use dma_zalloc_coherent
  lpfc: Use dma_zalloc_coherent
  megaraid: Use dma_zalloc_coherent
  mvsas: Use dma_zalloc_coherent
  qla2xxx: Use dma_zalloc_coherent
  qla4xxx: Use dma_zalloc_coherent
  usb: Use dma_zalloc_coherent
  fbdev: Use dma_zalloc_coherent
  sound: Use dma_zalloc_coherent

 arch/powerpc/platforms/pasemi/dma_lib.c   |  8 ++--
 arch/powerpc/sysdev/fsl_rmu.c |  9 ++--
 arch/sh/mm/consistent.c   |  4 +-
 drivers/ata/sata_fsl.c|  5 +--
 drivers/block/nvme-core.c |  5 +--
 drivers/crypto/amcc/crypto4xx_core.c  |  8 ++--
 drivers/crypto/ixp4xx_crypto.c|  8 ++--
 drivers/dma/imx-sdma.c|  5 +--
 drivers/dma/mxs-dma.c |  8 ++--
 drivers/gpu/drm/drm_pci.c |  6 +--
 drivers/infiniband/hw/cxgb3/cxio_hal.c|  7 ++--
 drivers/infiniband/hw/mthca/mthca_memfree.c   |  5 +--
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c  | 20 -
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c   |  6 +--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c   |  8 ++--
 drivers/mmc/host/msm_sdcc.c   |  8 ++--
 drivers/net/ethernet/broadcom/bcm63xx_enet.c  |  6 +--
 drivers/net/ethernet/hisilicon/hix5hd2_gmac.c |  5 +--
 drivers/net/ethernet/intel/ixgb/ixgb_main.c   |  6 +--
 drivers/net/wireless/ath/ath10k/pci.c |  8 +---
 drivers/net/wireless/ath/ath10k/wmi.c |  8 +---
 drivers/net/wireless/ath/wcn36xx/dxe.c|  6 +--
 drivers/net/wireless/rt2x00/rt2x00mmio.c  |  8 ++--
 drivers/scsi/bfa/bfad_bsg.c   |  6 +--
 drivers/scsi/bnx2fc/bnx2fc_hwi.c  | 59 ---
 drivers/scsi/bnx2fc/bnx2fc_tgt.c  | 51 ++-
 drivers/scsi/bnx2i/bnx2i_hwi.c| 14 +++
 drivers/scsi/dpt_i2o.c| 19 -
 drivers/scsi/lpfc/lpfc_bsg.c  |  5 +--
 drivers/scsi/lpfc/lpfc_init.c | 22 --
 drivers/scsi/lpfc/lpfc_mbox.c |  6 +--
 drivers/scsi/lpfc/lpfc_sli.c  | 14 +++
 drivers/scsi/megaraid/megaraid_sas_fusion.c   |  9 ++--
 drivers/scsi/mvsas/mv_init.c  | 26 +---
 drivers/scsi/qla2xxx/qla_init.c   | 10 ++---
 drivers/scsi/qla4xxx/ql4_init.c   |  5 +--
 drivers/scsi/qla4xxx/ql4_mbx.c| 21 --
 drivers/scsi/qla4xxx/ql4_nx.c |  5 +--
 drivers/scsi/qla4xxx/ql4_os.c | 12 +++---
 drivers/usb/dwc2/hcd_ddma.c   | 20 -
 drivers/usb/host/uhci-hcd.c   |  7 ++--
 drivers/video/fbdev/da8xx-fb.c|  9 ++--
 sound/aoa/soundbus/i2sbus/core.c  | 12 ++
 sound/sparc/dbri.c|  6 +--
 44 files changed, 197 insertions(+), 308 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/3] crypto: qce: Qualcomm crypto engine driver

2014-06-09 Thread Joe Perches
On Mon, 2014-06-09 at 15:08 +0300, Stanimir Varbanov wrote:
 The driver is separated by functional parts. The core part
 implements a platform driver probe and remove callbaks.
 The probe enables clocks, checks crypto version, initialize
 and request dma channels, create done tasklet and init
 crypto queue and finally register the algorithms into crypto
 core subsystem.

trivia:

 diff --git a/drivers/crypto/qce/dma.h b/drivers/crypto/qce/dma.h
[]
 +#define AUTH_NONCE_NUM_WORDS_SHIFT   20
 +#define AUTH_NONCE_NUM_WORDS_MASKGENMASK(22, 20);

Unnecessary semicolon and appears to be unused.

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 1/6] SP800-90A Deterministic Random Bit Generator

2014-04-14 Thread Joe Perches
On Tue, 2014-04-15 at 07:35 +0200, Stephan Mueller wrote:
 diff --git a/crypto/drbg.c b/crypto/drbg.c
[]
 @@ -0,0 +1,1997 @@
[]
 +/***
 + * Backend cipher definitions available to DRBG
 + ***/
 +
 +const struct drbg_core cores[] = {

cores isn't a very good global name.
I presume this should be static.


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/6] SP800-90A Deterministic Random Bit Generator

2014-04-11 Thread Joe Perches
On Fri, 2014-04-11 at 20:07 +0200, Stephan Mueller wrote:
 Changes v4:
  * change return codes of generate functions to signed int to convey error
codes and to match the kernel crypto API expecations on the generate
function.
  * add BUG_ON throughout drbg_healthcheck_sanity() since any failure should
should be caugth to prevent the DRBG from operating
  * change layout of debugging printk

It looks like const could be used a bit more often.

For instance:
perhaps uses of key could be changed to const unsigned char *key

 diff --git a/crypto/drbg.c b/crypto/drbg.c
[]
 +#ifdef CONFIG_CRYPTO_DRBG_CTR
 +static int drbg_kcapi_sym(struct drbg_state *drbg, unsigned char *key,
 +   unsigned char *outval, struct drbg_string *in);
[]
 +/* BCC function for CTR DRBG as defined in 10.4.3 */
 +static int drbg_ctr_bcc(struct drbg_state *drbg,
 + unsigned char *out, unsigned char *key,
 + struct drbg_string *in)
[]
 +/* Derivation Function for CTR DRBG as defined in 10.4.2 */
 +static int drbg_ctr_df(struct drbg_state *drbg,
 +unsigned char *df_data, size_t bytes_to_return,
 +struct drbg_string *addtl)
 +{
[]
 + unsigned char *K = (unsigned char *)
 +\x00\x01\x02\x03\x04\x05\x06\x07
 +\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f
 +\x10\x11\x12\x13\x14\x15\x16\x17
 +\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f;


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 02/14] crypto: omap-aes: Add useful debug macros

2013-08-17 Thread Joe Perches
On Sat, 2013-08-17 at 21:42 -0500, Joel Fernandes wrote:
 When DEBUG is enabled, these macros can be used to print variables in integer
 and hex format, and clearly display which registers, offsets and values are
 being read/written , including printing the names of the offsets and their 
 values.
 
 Note:
 This patch results in a checkpatch error that cannot be fixed.
 ERROR: Macros with multiple statements should be enclosed in a do - while loop
 +#define omap_aes_read(dd, offset)  \
 +   __raw_readl(dd-io_base + offset);  \
 +   pr_debug(omap_aes_read( #offset )\n);
 
 Using do-while loop will break a lot of code such as:
 ret = omap_aes_read(..);

That's where you use a statement expression macro

#define omap_aes_read(dd, offset)   \
({  \
pr_debug(omap_aes_read(omap_aes_read( #offset )\n);\
__raw_readl((dd)-iobase + offset); \
})


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/10] crypto: omap-aes: Add useful debug macros

2013-08-14 Thread Joe Perches
On Wed, 2013-08-14 at 18:12 -0500, Joel Fernandes wrote:
 When DEBUG is enabled, these macros can be used to print variables
 in integer and hex format, and clearly display which registers,
 offsets and values are being read/written , including printing the
 names of the offsets and their values.
[]
 diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
[]
 @@ -15,6 +15,14 @@
  
  #define pr_fmt(fmt) %s:  fmt, __func__
  
 +#ifdef DEBUG
 +#define prn(num) printk(#num =%d\n, num)
 +#define prx(num) printk(#num =%x\n, num)

pr_debug?

 +#else
 +#define prn(num) do { } while (0)
 +#define prx(num)  do { } while (0)
 +#endif
[]
 @@ -172,13 +180,35 @@ struct omap_aes_dev {
  static LIST_HEAD(dev_list);
  static DEFINE_SPINLOCK(list_lock);
  
 +#ifdef DEBUG
 +#define omap_aes_read(dd, offset)\
 + do {\
 + omap_aes_read_1(dd, offset);\
 + pr_debug(omap_aes_read( #offset )\n);   \
 + } while (0)
 +
 +static inline u32 omap_aes_read_1(struct omap_aes_dev *dd, u32 offset)
 +#else
  static inline u32 omap_aes_read(struct omap_aes_dev *dd, u32 offset)
 +#endif
  {
   return __raw_readl(dd-io_base + offset);
  }
  
 +#ifdef DEBUG
 +#define omap_aes_write(dd, offset, value)\
 + do {\
 + pr_debug(omap_aes_write( #offset =%x) value=%d\n,   \
 +  offset, value);\
 + omap_aes_write_1(dd, offset, value);\
 + } while (0)
 +
 +static inline void omap_aes_write_1(struct omap_aes_dev *dd, u32 offset,
 +   u32 value)
 +#else
  static inline void omap_aes_write(struct omap_aes_dev *dd, u32 offset,
 u32 value)
 +#endif
  {
   __raw_writel(value, dd-io_base + offset);
  }

Umm, yuck?

Is there any real value in read_1 and write_1?


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/10] crypto: omap-aes: Add useful debug macros

2013-08-14 Thread Joe Perches
On Wed, 2013-08-14 at 18:40 -0500, Joel Fernandes wrote:
 On 08/14/2013 06:29 PM, Joe Perches wrote:
  On Wed, 2013-08-14 at 18:12 -0500, Joel Fernandes wrote:
  When DEBUG is enabled, these macros can be used to print variables
  in integer and hex format, and clearly display which registers,
  offsets and values are being read/written , including printing the
  names of the offsets and their values.
  []
  diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
  []
  @@ -15,6 +15,14 @@
   
   #define pr_fmt(fmt) %s:  fmt, __func__
   
  +#ifdef DEBUG
  +#define prn(num) printk(#num =%d\n, num)
  +#define prx(num) printk(#num =%x\n, num)
  
  pr_debug?
 
 Sure, can change that.
 
  +#else
  +#define prn(num) do { } while (0)
  +#define prx(num)  do { } while (0)
  +#endif
  []
  @@ -172,13 +180,35 @@ struct omap_aes_dev {
   static LIST_HEAD(dev_list);
   static DEFINE_SPINLOCK(list_lock);
   
  +#ifdef DEBUG
  +#define omap_aes_read(dd, offset) \
  +  do {\
  +  omap_aes_read_1(dd, offset);\
  +  pr_debug(omap_aes_read( #offset )\n);   \
  +  } while (0)
  +
  +static inline u32 omap_aes_read_1(struct omap_aes_dev *dd, u32 offset)
  +#else
   static inline u32 omap_aes_read(struct omap_aes_dev *dd, u32 offset)
  +#endif
   {
 return __raw_readl(dd-io_base + offset);
   }
   
  +#ifdef DEBUG
  +#define omap_aes_write(dd, offset, value) \
  +  do {\
  +  pr_debug(omap_aes_write( #offset =%x) value=%d\n,   \
  +   offset, value);\
  +  omap_aes_write_1(dd, offset, value);\
  +  } while (0)
  +
  +static inline void omap_aes_write_1(struct omap_aes_dev *dd, u32 offset,
  +u32 value)
  +#else
   static inline void omap_aes_write(struct omap_aes_dev *dd, u32 offset,
   u32 value)
  +#endif
   {
 __raw_writel(value, dd-io_base + offset);
   }
  
  Umm, yuck?
  
  Is there any real value in read_1 and write_1?
 
 Can you be more descriptive? There is a lot of value in them for debug
 to show clearly sequence of read/writes. Moreover, they are no-op'd when
 DEBUG is disabled.

pr_debug is no-op'd when DEBUG is not #defined.
so just use a single

omap_aes_write(...)
{
pr_debug(...)
__raw_writel(...);
}


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/5] crypto/camellia_generic.c: convert comma to semicolon

2013-08-10 Thread Joe Perches
On Sat, 2013-08-10 at 17:40 +0200, Julia Lawall wrote:
 Replace a comma between expression statements by a semicolon.
[]
 This patch is separate from the others because the code appears to be
 machine-generated.

It may have once been machine generated, but it's not now.
It's been modified several times by human generated patches.

 diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
[]
 @@ -388,7 +388,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, 
 u32 *subR, int max)
[]
 - dw = subL[1]  subL[9],
 + dw = subL[1]  subL[9];
   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl2) */

Perhaps you can (auto?) fix the indentation
on the next line too?

 @@ -397,7 +397,7 @@ static void camellia_setup_tail(u32 *subkey, u32 *subL, 
 u32 *subR, int max)
[]
 - dw = subL[1]  subL[17],
 + dw = subL[1]  subL[17];
   subR[1] ^= rol32(dw, 1); /* modified for FLinv(kl4) */

etc...


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: crypto: ux500: Fix logging, make arrays const, neatening

2013-07-22 Thread Joe Perches
On Tue, 2013-07-23 at 00:35 +0200, Linus Walleij wrote:
 Have you tested this on hardware or is it compile-tested only?

Hi Linus.

Compile tested only.  Not tested on real devices.  -ENOHARDWARE.

cheers, Joe

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


crypto: ux500: Fix logging, make arrays const, neatening

2013-07-16 Thread Joe Perches
Logging messages without newlines are possibly interleaved
with other messages.  Add terminating newlines to avoid
this.

Other miscellaneous changes:

Make arrays const to reduce data size
Add pr_fmt to prefix pr_level, remove now unused DEV_DBG_NAME
Coalesce formats, align arguments
Remove unnecessary OOM messages as dump_stack is already done
Remove unnecessary cast of void *
Change kzalloc(sizeof(struct)...) to kzalloc(sizeof(*var), ...)
Reduce indents in struct definitions

Signed-off-by: Joe Perches j...@perches.com
---

On top of Masanari Iida's patch:
https://patchwork.kernel.org/patch/2828273/

 drivers/crypto/ux500/hash/hash_core.c | 586 --
 1 file changed, 279 insertions(+), 307 deletions(-)

diff --git a/drivers/crypto/ux500/hash/hash_core.c 
b/drivers/crypto/ux500/hash/hash_core.c
index 496ae6a..4cbc962 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -11,6 +11,8 @@
  * License terms: GNU General Public License (GPL) version 2
  */
 
+#define pr_fmt(fmt) hashX hashX:  fmt
+
 #include linux/clk.h
 #include linux/device.h
 #include linux/err.h
@@ -35,8 +37,6 @@
 
 #include hash_alg.h
 
-#define DEV_DBG_NAME hashX hashX:
-
 static int hash_mode;
 module_param(hash_mode, int, 0);
 MODULE_PARM_DESC(hash_mode, CPU or DMA mode. CPU = 0 (default), DMA = 1);
@@ -44,13 +44,13 @@ MODULE_PARM_DESC(hash_mode, CPU or DMA mode. CPU = 0 
(default), DMA = 1);
 /**
  * Pre-calculated empty message digests.
  */
-static u8 zero_message_hash_sha1[SHA1_DIGEST_SIZE] = {
+static const u8 zero_message_hash_sha1[SHA1_DIGEST_SIZE] = {
0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d,
0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90,
0xaf, 0xd8, 0x07, 0x09
 };
 
-static u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = {
+static const u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = {
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14,
0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24,
0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c,
@@ -58,14 +58,14 @@ static u8 zero_message_hash_sha256[SHA256_DIGEST_SIZE] = {
 };
 
 /* HMAC-SHA1, no key */
-static u8 zero_message_hmac_sha1[SHA1_DIGEST_SIZE] = {
+static const u8 zero_message_hmac_sha1[SHA1_DIGEST_SIZE] = {
0xfb, 0xdb, 0x1d, 0x1b, 0x18, 0xaa, 0x6c, 0x08,
0x32, 0x4b, 0x7d, 0x64, 0xb7, 0x1f, 0xb7, 0x63,
0x70, 0x69, 0x0e, 0x1d
 };
 
 /* HMAC-SHA256, no key */
-static u8 zero_message_hmac_sha256[SHA256_DIGEST_SIZE] = {
+static const u8 zero_message_hmac_sha256[SHA256_DIGEST_SIZE] = {
0xb6, 0x13, 0x67, 0x9a, 0x08, 0x14, 0xd9, 0xec,
0x77, 0x2f, 0x95, 0xd7, 0x78, 0xc3, 0x5f, 0xc5,
0xff, 0x16, 0x97, 0xc4, 0x93, 0x71, 0x56, 0x53,
@@ -97,7 +97,7 @@ static struct hash_driver_datadriver_data;
  *
  */
 static void hash_messagepad(struct hash_device_data *device_data,
-   const u32 *message, u8 index_bytes);
+   const u32 *message, u8 index_bytes);
 
 /**
  * release_hash_device - Releases a previously allocated hash device.
@@ -119,7 +119,7 @@ static void release_hash_device(struct hash_device_data 
*device_data)
 }
 
 static void hash_dma_setup_channel(struct hash_device_data *device_data,
-   struct device *dev)
+  struct device *dev)
 {
struct hash_platform_data *platform_data = dev-platform_data;
struct dma_slave_config conf = {
@@ -127,7 +127,7 @@ static void hash_dma_setup_channel(struct hash_device_data 
*device_data,
.dst_addr = device_data-phybase + HASH_DMA_FIFO,
.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
.dst_maxburst = 16,
-};
+   };
 
dma_cap_zero(device_data-dma.mask);
dma_cap_set(DMA_SLAVE, device_data-dma.mask);
@@ -135,8 +135,8 @@ static void hash_dma_setup_channel(struct hash_device_data 
*device_data,
device_data-dma.cfg_mem2hash = platform_data-mem_to_engine;
device_data-dma.chan_mem2hash =
dma_request_channel(device_data-dma.mask,
-   platform_data-dma_filter,
-   device_data-dma.cfg_mem2hash);
+   platform_data-dma_filter,
+   device_data-dma.cfg_mem2hash);
 
dmaengine_slave_config(device_data-dma.chan_mem2hash, conf);
 
@@ -145,21 +145,21 @@ static void hash_dma_setup_channel(struct 
hash_device_data *device_data,
 
 static void hash_dma_callback(void *data)
 {
-   struct hash_ctx *ctx = (struct hash_ctx *) data;
+   struct hash_ctx *ctx = data;
 
complete(ctx-device-dma.complete);
 }
 
 static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg,
-   int len, enum dma_data_direction direction)
+int len, enum dma_data_direction direction)
 {
struct

[PATCH 1/2] crypto: Remove global #define PFX and use, use pr_level

2011-12-18 Thread Joe Perches
PFX is not a good #define to have in a system #include.
Use pr_fmt and pr_level instead.

Signed-off-by: Joe Perches j...@perches.com
---
 drivers/char/hw_random/via-rng.c |   12 ++--
 drivers/crypto/padlock-aes.c |   10 ++
 drivers/crypto/padlock-sha.c |   14 --
 include/crypto/padlock.h |2 --
 4 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index d0387a8..c4a7f11 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -24,6 +24,8 @@
  * warranty of any kind, whether express or implied.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
 #include crypto/padlock.h
 #include linux/module.h
 #include linux/kernel.h
@@ -140,8 +142,7 @@ static int via_rng_init(struct hwrng *rng)
 * register */
if ((c-x86 == 6)  (c-x86_model = 0x0f)) {
if (!cpu_has_xstore_enabled) {
-   printk(KERN_ERR PFX can't enable hardware RNG 
-   if XSTORE is not enabled\n);
+   pr_err(can't enable hardware RNG if XSTORE is not 
enabled\n);
return -ENODEV;
}
return 0;
@@ -179,7 +180,7 @@ static int via_rng_init(struct hwrng *rng)
   unneeded */
rdmsr(MSR_VIA_RNG, lo, hi);
if ((lo  VIA_RNG_ENABLE) == 0) {
-   printk(KERN_ERR PFX cannot enable VIA C3 RNG, aborting\n);
+   pr_err(cannot enable VIA C3 RNG, aborting\n);
return -ENODEV;
}
 
@@ -201,11 +202,10 @@ static int __init mod_init(void)
 
if (!cpu_has_xstore)
return -ENODEV;
-   printk(KERN_INFO VIA RNG detected\n);
+   pr_info(VIA RNG detected\n);
err = hwrng_register(via_rng);
if (err) {
-   printk(KERN_ERR PFX RNG registering failed (%d)\n,
-  err);
+   pr_err(RNG registering failed (%d)\n, err);
goto out;
}
 out:
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 29b9469..0dad679 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -7,6 +7,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
 #include crypto/algapi.h
 #include crypto/aes.h
 #include crypto/padlock.h
@@ -512,7 +514,7 @@ static int __init padlock_init(void)
return -ENODEV;
 
if (!cpu_has_xcrypt_enabled) {
-   printk(KERN_NOTICE PFX VIA PadLock detected, but not enabled. 
Hmm, strange...\n);
+   pr_notice(VIA PadLock detected, but not enabled. Hmm, 
strange...\n);
return -ENODEV;
}
 
@@ -525,12 +527,12 @@ static int __init padlock_init(void)
if ((ret = crypto_register_alg(cbc_aes_alg)))
goto cbc_aes_err;
 
-   printk(KERN_NOTICE PFX Using VIA PadLock ACE for AES algorithm.\n);
+   pr_notice(Using VIA PadLock ACE for AES algorithm\n);
 
if (c-x86 == 6  c-x86_model == 15  c-x86_mask == 2) {
ecb_fetch_blocks = MAX_ECB_FETCH_BLOCKS;
cbc_fetch_blocks = MAX_CBC_FETCH_BLOCKS;
-   printk(KERN_NOTICE PFX VIA Nano stepping 2 detected: enabling 
workaround.\n);
+   pr_notice(VIA Nano stepping 2 detected: enabling 
workaround\n);
}
 
 out:
@@ -541,7 +543,7 @@ cbc_aes_err:
 ecb_aes_err:
crypto_unregister_alg(aes_alg);
 aes_err:
-   printk(KERN_ERR PFX VIA PadLock AES initialization failed.\n);
+   pr_err(VIA PadLock AES initialization failed\n);
goto out;
 }
 
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index 06bdb4b..dad4585 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -12,6 +12,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
 #include crypto/internal/hash.h
 #include crypto/padlock.h
 #include crypto/sha.h
@@ -219,8 +221,8 @@ static int padlock_cra_init(struct crypto_tfm *tfm)
fallback_tfm = crypto_alloc_shash(fallback_driver_name, 0,
  CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback_tfm)) {
-   printk(KERN_WARNING PFX Fallback driver '%s' could not be 
loaded!\n,
-  fallback_driver_name);
+   pr_warn(Fallback driver '%s' could not be loaded!\n,
+   fallback_driver_name);
err = PTR_ERR(fallback_tfm);
goto out;
}
@@ -534,12 +536,12 @@ static int __init padlock_init(void)
struct shash_alg *sha256;
 
if (!cpu_has_phe) {
-   printk(KERN_NOTICE PFX VIA PadLock Hash Engine not 
detected.\n);
+   pr_notice(VIA PadLock Hash Engine not detected\n);
return -ENODEV;
}
 
if (!cpu_has_phe_enabled) {
-   printk(KERN_NOTICE PFX VIA PadLock detected, but not enabled. 
Hmm

drivers/crypto/picoxcell_crypto.c: boolean and / or confusion

2011-12-12 Thread Joe Perches
On Tue, 2011-12-13 at 00:06 +0100, roel wrote:
 The test not [val1] or not [val2] always evaluates to true

Hey Jamie and Roel

Looking at drivers with:

$ grep -rP --include=*.[ch] 
(\b[\w\[\]\\._\-]+)\s*\!\=\s*[\w\[\]\\._\-]+\s*\|\|\s*\1\s*\!\= drivers

drivers/crypto/picoxcell_crypto.c:  if ((len != AES_KEYSIZE_128 || len != 
AES_KEYSIZE_256) 
drivers/crypto/picoxcell_crypto.c:  } else if ((len != AES_KEYSIZE_128 || 
len != AES_KEYSIZE_256) 

Most likely these should be  not ||.

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


drivers/media/video/s5p-fimc/fimc-capture.c: boolean and / or confusion

2011-12-12 Thread Joe Perches
On Tue, 2011-12-13 at 00:06 +0100, roel wrote:
 The test not [val1] or not [val2] always evaluates to true

Hello

Looking at drivers with:

$ grep -rP --include=*.[ch] 
(\b[\w\[\]\\._\-]+)\s*\!\=\s*[\w\[\]\\._\-]+\s*\|\|\s*\1\s*\!\= drivers

drivers/media/video/s5p-fimc/fimc-capture.c:if (mf-width != 
tfmt-width || mf-width != tfmt-width) {
drivers/media/video/s5p-fimc/fimc-capture.c:if (mf-width 
!= tfmt-width || mf-width != tfmt-width)

Most likely these tests should be:
if (mf-height != tfmt-height || mf-width != tfmt-width)



--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] treewide: Update sha_transform

2011-08-09 Thread Joe Perches
Move the workspace into sha_transform as local stack variable struct.

Remove #define SHA_WORKSPACE_WORDS.
Remove workspace argument from sha_transform.
Convert uses of __u8 * to void * in sha_transform.
Eliminate possible sha_transform unaligned accesses to data by copying
data to an aligned __u32 array if necessary.
Add sha_transform wipe argument to force workspace clearing if desired.
A little macro neatening.

This should speed network syncookies a trivial bit.

Add #include linux/cryptohash.h to lib/sha1.c

Compiled/untested.

Signed-off-by: Joe Perches j...@perches.com
---

On Mon, 2011-08-08 at 22:52 -0700, Mandeep Singh Baines wrote:
 We don't call sha_tranform directly. We use crypto_hash_digest. So maybe
 add a wipe param there. I'm happy to work on or test such a patch if folks
 think its interesting. Its saves me 190 ms on a 6 second boot. I suspect
 there may be other hash intense applications that also don't need secracy.
 
Well, here's the patch I produced.

 crypto/sha1_generic.c  |5 +---
 drivers/char/random.c  |7 ++---
 include/linux/cryptohash.h |3 +-
 lib/sha1.c |   61 +++-
 net/ipv4/syncookies.c  |5 +--
 net/ipv4/tcp_output.c  |6 +---
 net/ipv6/syncookies.c  |5 +--
 7 files changed, 54 insertions(+), 38 deletions(-)

diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
index 00ae60e..d0c3f4a 100644
--- a/crypto/sha1_generic.c
+++ b/crypto/sha1_generic.c
@@ -49,8 +49,6 @@ static int sha1_update(struct shash_desc *desc, const u8 
*data,
src = data;
 
if ((partial + len) = SHA1_BLOCK_SIZE) {
-   u32 temp[SHA_WORKSPACE_WORDS];
-
if (partial) {
done = -partial;
memcpy(sctx-buffer + partial, data,
@@ -59,12 +57,11 @@ static int sha1_update(struct shash_desc *desc, const u8 
*data,
}
 
do {
-   sha_transform(sctx-state, src, temp);
+   sha_transform(sctx-state, src, true);
done += SHA1_BLOCK_SIZE;
src = data + done;
} while (done + SHA1_BLOCK_SIZE = len);
 
-   memset(temp, 0, sizeof(temp));
partial = 0;
}
memcpy(sctx-buffer + partial, src, len - done);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index c35a785..6b9e5dc 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -816,13 +816,13 @@ static size_t account(struct entropy_store *r, size_t 
nbytes, int min,
 static void extract_buf(struct entropy_store *r, __u8 *out)
 {
int i;
-   __u32 hash[5], workspace[SHA_WORKSPACE_WORDS];
+   __u32 hash[5];
__u8 extract[64];
 
/* Generate a hash across the pool, 16 words (512 bits) at a time */
sha_init(hash);
for (i = 0; i  r-poolinfo-poolwords; i += 16)
-   sha_transform(hash, (__u8 *)(r-pool + i), workspace);
+   sha_transform(hash, r-pool + i, false);
 
/*
 * We mix the hash back into the pool to prevent backtracking
@@ -839,9 +839,8 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
 * To avoid duplicates, we atomically extract a portion of the
 * pool while mixing, and hash one final time.
 */
-   sha_transform(hash, extract, workspace);
+   sha_transform(hash, extract, true);
memset(extract, 0, sizeof(extract));
-   memset(workspace, 0, sizeof(workspace));
 
/*
 * In case the hash function has some recognizable output
diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h
index 2cd9f1c..c64b5cf 100644
--- a/include/linux/cryptohash.h
+++ b/include/linux/cryptohash.h
@@ -3,10 +3,9 @@
 
 #define SHA_DIGEST_WORDS 5
 #define SHA_MESSAGE_BYTES (512 /*bits*/ / 8)
-#define SHA_WORKSPACE_WORDS 16
 
 void sha_init(__u32 *buf);
-void sha_transform(__u32 *digest, const char *data, __u32 *W);
+void sha_transform(__u32 *digest, const void *data, bool wipe);
 
 #define MD5_DIGEST_WORDS 4
 #define MD5_MESSAGE_BYTES 64
diff --git a/lib/sha1.c b/lib/sha1.c
index f33271d..a78ca29 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -8,6 +8,7 @@
 #include linux/kernel.h
 #include linux/module.h
 #include linux/bitops.h
+#include linux/cryptohash.h
 #include asm/unaligned.h
 
 /*
@@ -41,45 +42,66 @@
 #endif
 
 /* This rolls over the 512-bit array */
-#define W(x) (array[(x)15])
+#define W(x) (workspace.array[(x)15])
 
 /*
  * Where do we get the source from? The first 16 iterations get it from
  * the input data, the next mix it from the 512-bit array.
  */
-#define SHA_SRC(t) get_unaligned_be32((__u32 *)data + t)
+#define SHA_SRC(t) (workspace.aligned_data[t])
 #define SHA_MIX(t) rol32(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1)
 
-#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \
-   __u32 TEMP = input(t); setW(t, TEMP); \
-   E

Re: [PATCH] lib/sha1: remove memsets and allocate workspace on the stack

2011-08-08 Thread Joe Perches
On Mon, 2011-08-08 at 16:07 -0700, Mandeep Singh Baines wrote:
 The previous implementation required the workspace to be passed in as
 a parameter. This prevents the compiler from being able to store the
 workspace in registers. I've also removed the memset since that also
 prevents the compiler from storing the workspace in registers.

I did a similar patch locally.

 There is no loss of security due to removing the memset. It would be a
 bug for the stack to leak to userspace. However, a defence-in-depth
 argument could be made for keeping the clearing of the workspace.

You should add #include linux/crypthash.h to
lib/sha1.c and perhaps rationalize the use of __u8
and char for the second argument to sha_transform in
the definition and uses.

For defense in depth, a bool could be added to sha_transform
like:

void sha_transform(__u32 *digest, const char *data, bool wipe);

and the internal workspace memset after use if wipe set though
perhaps the memset could be a compile time option like
CONFIG_CRYPTO_DEFENSE_IN_DEPTH or such instead.

 diff --git a/drivers/char/random.c b/drivers/char/random.c
[]
 @@ -816,13 +816,13 @@ static size_t account(struct entropy_store *r, size_t 
 nbytes, int min,
  static void extract_buf(struct entropy_store *r, __u8 *out)
[]
 - sha_transform(hash, (__u8 *)(r-pool + i), workspace);
 + sha_transform(hash, (__u8 *)(r-pool + i));
[]
 diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h
[]
 @@ -3,10 +3,9 @@
[]
 -void sha_transform(__u32 *digest, const char *data, __u32 *W);
 +void sha_transform(__u32 *digest, const char *data);
[]
 diff --git a/lib/sha1.c b/lib/sha1.c
[]
 +void sha_transform(__u32 *digest, const char *data)
[]
 diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
[]
 @@ -50,7 +49,7 @@ static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 
 sport, __be16 dport,
[]
 - sha_transform(tmp + 16, (__u8 *)tmp, tmp + 16 + 5);
 + sha_transform(tmp + 16, (__u8 *)tmp);
[]
 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
[]
 @@ -2511,8 +2510,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct 
 dst_entry *dst,
[]
   sha_transform((__u32 *)xvp-cookie_bakery[0],
 -   (char *)mess,
 -   workspace[0]);
 +   (char *)mess);
[]
 diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
[]
 @@ -81,7 +80,7 @@ static u32 cookie_hash(const struct in6_addr *saddr, const 
 struct in6_addr *dadd
[]
 - sha_transform(tmp + 16, (__u8 *)tmp, tmp + 16 + 5);
 + sha_transform(tmp + 16, (__u8 *)tmp);


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] treewide: Remove direct uses of SHA_WORKSPACE_WORDS

2011-08-07 Thread Joe Perches
While not connected to ARM's implementation of sha_transform,
maybe this might make code a bit clearer.

Remove need to know the size and type of SHA_WORKSPACE_WORDS.
Introduce and use opaque struct sha_workspace instead.

Add #include linux/cryptohash.h to lib/sha1.c

Signed-off-by: Joe Perches j...@perches.com
---
 crypto/sha1_generic.c  |6 +++---
 drivers/char/random.c  |9 +
 include/linux/cryptohash.h |7 ++-
 lib/sha1.c |7 +--
 net/ipv4/syncookies.c  |7 ---
 net/ipv4/tcp_output.c  |4 ++--
 net/ipv6/syncookies.c  |7 ---
 7 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
index 00ae60e..639b507 100644
--- a/crypto/sha1_generic.c
+++ b/crypto/sha1_generic.c
@@ -49,7 +49,7 @@ static int sha1_update(struct shash_desc *desc, const u8 
*data,
src = data;
 
if ((partial + len) = SHA1_BLOCK_SIZE) {
-   u32 temp[SHA_WORKSPACE_WORDS];
+   struct sha_workspace temp;
 
if (partial) {
done = -partial;
@@ -59,12 +59,12 @@ static int sha1_update(struct shash_desc *desc, const u8 
*data,
}
 
do {
-   sha_transform(sctx-state, src, temp);
+   sha_transform(sctx-state, src, temp);
done += SHA1_BLOCK_SIZE;
src = data + done;
} while (done + SHA1_BLOCK_SIZE = len);
 
-   memset(temp, 0, sizeof(temp));
+   memset(temp, 0, sizeof(temp));
partial = 0;
}
memcpy(sctx-buffer + partial, src, len - done);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index c35a785..bd0fd99 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -816,13 +816,14 @@ static size_t account(struct entropy_store *r, size_t 
nbytes, int min,
 static void extract_buf(struct entropy_store *r, __u8 *out)
 {
int i;
-   __u32 hash[5], workspace[SHA_WORKSPACE_WORDS];
+   __u32 hash[5];
+   struct sha_workspace workspace;
__u8 extract[64];
 
/* Generate a hash across the pool, 16 words (512 bits) at a time */
sha_init(hash);
for (i = 0; i  r-poolinfo-poolwords; i += 16)
-   sha_transform(hash, (__u8 *)(r-pool + i), workspace);
+   sha_transform(hash, (__u8 *)(r-pool + i), workspace);
 
/*
 * We mix the hash back into the pool to prevent backtracking
@@ -839,9 +840,9 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
 * To avoid duplicates, we atomically extract a portion of the
 * pool while mixing, and hash one final time.
 */
-   sha_transform(hash, extract, workspace);
+   sha_transform(hash, extract, workspace);
memset(extract, 0, sizeof(extract));
-   memset(workspace, 0, sizeof(workspace));
+   memset(workspace, 0, sizeof(workspace));
 
/*
 * In case the hash function has some recognizable output
diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h
index 2cd9f1c..18b3a27 100644
--- a/include/linux/cryptohash.h
+++ b/include/linux/cryptohash.h
@@ -5,8 +5,13 @@
 #define SHA_MESSAGE_BYTES (512 /*bits*/ / 8)
 #define SHA_WORKSPACE_WORDS 16
 
+struct sha_workspace {
+   __u32 words[SHA_WORKSPACE_WORDS];
+};
+
 void sha_init(__u32 *buf);
-void sha_transform(__u32 *digest, const char *data, __u32 *W);
+void sha_transform(__u32 *digest, const char *data,
+  struct sha_workspace *workspace);
 
 #define MD5_DIGEST_WORDS 4
 #define MD5_MESSAGE_BYTES 64
diff --git a/lib/sha1.c b/lib/sha1.c
index f33271d..990612a 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -8,6 +8,7 @@
 #include linux/kernel.h
 #include linux/module.h
 #include linux/bitops.h
+#include linux/cryptohash.h
 #include asm/unaligned.h
 
 /*
@@ -66,7 +67,7 @@
  *
  * @digest: 160 bit digest to update
  * @data:   512 bits of data to hash
- * @array:  16 words of workspace (see note)
+ * @workspace:  struct sha_workspace * (see note)
  *
  * This function generates a SHA1 digest for a single 512-bit block.
  * Be warned, it does not handle padding and message digest, do not
@@ -77,9 +78,11 @@
  * to clear the workspace. This is left to the caller to avoid
  * unnecessary clears between chained hashing operations.
  */
-void sha_transform(__u32 *digest, const char *data, __u32 *array)
+void sha_transform(__u32 *digest, const char *data,
+  struct sha_workspace *workspace)
 {
__u32 A, B, C, D, E;
+   __u32 *array = workspace-words;
 
A = digest[0];
B = digest[1];
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 92bb943..77e8069 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -37,20 +37,21 @@ __initcall(init_syncookies);
 #define COOKIEBITS 24  /* Upper bits store count */
 #define COOKIEMASK

Re: [PATCH] crypto: sha1: modify sha1_update to use SHA1_BLOCK_SIZE

2011-05-25 Thread Joe Perches
On Wed, 2011-05-25 at 23:34 -0400, David Miller wrote:
 From: Mandeep Singh Baines m...@chromium.org
 Date: Wed, 25 May 2011 20:11:17 -0700
  Plus some other minor cleanup.
  Signed-off-by: Mandeep Singh Baines m...@chromium.org
 The temp[] buffer is explicitly places inside the inner most
 basic block so that the compiler doesn't allocate the stack
 space unless that code path is taken.

Does any version of gcc manage to do that?

Regardless, it's still a good idea to keep
declarations in the use scope.


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/49] crypto: Use vzalloc

2010-11-04 Thread Joe Perches
Signed-off-by: Joe Perches j...@perches.com
---
 crypto/deflate.c |3 +--
 crypto/zlib.c|3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/crypto/deflate.c b/crypto/deflate.c
index 463dc85..cbc7a33 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -48,12 +48,11 @@ static int deflate_comp_init(struct deflate_ctx *ctx)
int ret = 0;
struct z_stream_s *stream = ctx-comp_stream;
 
-   stream-workspace = vmalloc(zlib_deflate_workspacesize());
+   stream-workspace = vzalloc(zlib_deflate_workspacesize());
if (!stream-workspace) {
ret = -ENOMEM;
goto out;
}
-   memset(stream-workspace, 0, zlib_deflate_workspacesize());
ret = zlib_deflateInit2(stream, DEFLATE_DEF_LEVEL, Z_DEFLATED,
-DEFLATE_DEF_WINBITS, DEFLATE_DEF_MEMLEVEL,
Z_DEFAULT_STRATEGY);
diff --git a/crypto/zlib.c b/crypto/zlib.c
index c3015733..739b8fc 100644
--- a/crypto/zlib.c
+++ b/crypto/zlib.c
@@ -95,11 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, 
void *params,
zlib_comp_exit(ctx);
 
workspacesize = zlib_deflate_workspacesize();
-   stream-workspace = vmalloc(workspacesize);
+   stream-workspace = vzalloc(workspacesize);
if (!stream-workspace)
return -ENOMEM;
 
-   memset(stream-workspace, 0, workspacesize);
ret = zlib_deflateInit2(stream,
tb[ZLIB_COMP_LEVEL]
? nla_get_u32(tb[ZLIB_COMP_LEVEL])
-- 
1.7.3.1.g432b3.dirty

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] SCRIPTS: Fix whitespace in get_maintainer output

2010-02-09 Thread Joe Perches
On Wed, 2010-02-10 at 01:37 +0100, Richard Hartmann wrote:
 - warn $P: file '${file}' doesn't appear to be a patch.  
 + warn $P: file '${file}' doesn't appear to be a patch. 

One space not two after periods?  Horrors.

Well if you like, but that's not what I like.

Not-acked-by-but-not-specifically-rejected-by etc.

cheers, Joe

FULL STOP

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/21] crypto/async_tx/raid6test.c: use pr_level and add pr_fmt(fmt)

2009-10-04 Thread Joe Perches
Added #define pr_fmt(fmt) KBUILD_MODNAME :  fmt
Converted pr( to pr_info(
Removed #define pr pr_info(raid6test: 

Signed-off-by: Joe Perches j...@perches.com
---
 crypto/async_tx/raid6test.c |   30 +++---
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/crypto/async_tx/raid6test.c b/crypto/async_tx/raid6test.c
index 3ec27c7..bcf762c 100644
--- a/crypto/async_tx/raid6test.c
+++ b/crypto/async_tx/raid6test.c
@@ -19,12 +19,12 @@
  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
 #include linux/async_tx.h
 #include linux/random.h
 
-#undef pr
-#define pr(fmt, args...) pr_info(raid6test:  fmt, ##args)
-
 #define NDISKS 16 /* Including P and Q */
 
 static struct page *dataptrs[NDISKS];
@@ -121,12 +121,12 @@ static void raid6_dual_recov(int disks, size_t bytes, int 
faila, int failb, stru
async_tx_issue_pending(tx);
 
if (wait_for_completion_timeout(cmp, msecs_to_jiffies(3000)) == 0)
-   pr(%s: timeout! (faila: %d failb: %d disks: %d)\n,
-  __func__, faila, failb, disks);
+   pr_info(%s: timeout! (faila: %d failb: %d disks: %d)\n,
+   __func__, faila, failb, disks);
 
if (result != 0)
-   pr(%s: validation failure! faila: %d failb: %d 
sum_check_flags: %x\n,
-  __func__, faila, failb, result);
+   pr_info(%s: validation failure! faila: %d failb: %d 
sum_check_flags: %x\n,
+   __func__, faila, failb, result);
 }
 
 static int test_disks(int i, int j, int disks)
@@ -144,9 +144,9 @@ static int test_disks(int i, int j, int disks)
erra = memcmp(page_address(data[i]), page_address(recovi), PAGE_SIZE);
errb = memcmp(page_address(data[j]), page_address(recovj), PAGE_SIZE);
 
-   pr(%s(%d, %d): faila=%3d(%c)  failb=%3d(%c)  %s\n,
-  __func__, i, j, i, disk_type(i, disks), j, disk_type(j, disks),
-  (!erra  !errb) ? OK : !erra ? ERRB : !errb ? ERRA : ERRAB);
+   pr_info(%s(%d, %d): faila=%3d(%c)  failb=%3d(%c)  %s\n,
+   __func__, i, j, i, disk_type(i, disks), j, disk_type(j, disks),
+   (!erra  !errb) ? OK : !erra ? ERRB : !errb ? ERRA : 
ERRAB);
 
dataptrs[i] = data[i];
dataptrs[j] = data[j];
@@ -179,11 +179,11 @@ static int test(int disks, int *tests)
async_tx_issue_pending(tx);
 
if (wait_for_completion_timeout(cmp, msecs_to_jiffies(3000)) == 0) {
-   pr(error: initial gen_syndrome(%d) timed out\n, disks);
+   pr_info(error: initial gen_syndrome(%d) timed out\n, disks);
return 1;
}
 
-   pr(testing the %d-disk case...\n, disks);
+   pr_info(testing the %d-disk case...\n, disks);
for (i = 0; i  disks-1; i++)
for (j = i+1; j  disks; j++) {
(*tests)++;
@@ -216,9 +216,9 @@ static int raid6_test(void)
err += test(5, tests);
err += test(NDISKS, tests);
 
-   pr(\n);
-   pr(complete (%d tests, %d failure%s)\n,
-  tests, err, err == 1 ?  : s);
+   pr_info(\n);
+   pr_info(complete (%d tests, %d failure%s)\n,
+   tests, err, err == 1 ?  : s);
 
for (i = 0; i  NDISKS+3; i++)
put_page(data[i]);
-- 
1.6.3.1.10.g659a0.dirty

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/21] pr_dbg, pr_fmt

2009-10-04 Thread Joe Perches
One possible long term goal is to stop adding
#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
to source files to prefix modulename to logging output.

It might be useful to eventually have kernel.h
use a standard #define pr_fmt which includes KBUILD_MODNAME
instead of a blank or empty define.

Perhaps over time, the source modules that use pr_level
with prefixes can be converted to use pr_fmt.

If all modules are converted, that will allow the printk
routine to add module/filename/line/offset to the logging
lines using some function similar to dynamic_debug and
substantially reduct object string use by removing the
repeated prefixes.

This patchset does not get to that result.  The patches
right now uses _more_ string space because all logging
messages have unshared prefixes but it may be a useful start.

The patchset strips prefixes from printks and adds pr_fmt to
arch/x86, crypto, kernel, and a few drivers.

It also converts printk(KERN_level to pr_level in a few files
that already had some pr_level uses.

The conversion also generally used long length format strings
in the place of multiple short strings to ease any grep/search.
 
Joe Perches (21):
  include/linux/ dynamic_debug.h kernel.h: Remove KBUILD_MODNAME from 
dynamic_pr_debug, add #define pr_dbg
  ftrace.c: Add #define pr_fmt(fmt) KBUILD_MODNAME :  fmt
  mtrr: use pr_level and pr_fmt
  microcode: use pr_level and add pr_fmt
  amd_iommu.c: use pr_level and add pr_fmt(fmt)
  es7000_32.c: use pr_level and add pr_fmt(fmt)
  arch/x86/kernel/apic/: use pr_level and add pr_fmt(fmt)
  mcheck/: use pr_level and add pr_fmt(fmt)
  arch/x86/kernel/setup_percpu.c: use pr_level and add pr_fmt(fmt)
  arch/x86/kernel/cpu/: use pr_level and add pr_fmt(fmt)
  i8254.c: Add pr_fmt(fmt)
  kmmio.c: Add and use pr_fmt(fmt)
  testmmiotrace.c: Add and use pr_fmt(fmt)
  crypto/: use pr_level and add pr_fmt(fmt)
  kernel/power/: use pr_level and add pr_fmt(fmt)
  kernel/kexec.c: use pr_level and add pr_fmt(fmt)
  crypto/async_tx/raid6test.c: use pr_level and add pr_fmt(fmt)
  arch/x86/mm/mmio-mod.c: use pr_fmt
  drivers/net/bonding/: : use pr_fmt
  drivers/net/tlan: use pr_level and add pr_fmt(fmt)
  drivers/net/tlan.h: Convert printk(KERN_DEBUG to pr_dbg(

 arch/x86/kernel/amd_iommu.c|   71 ++--
 arch/x86/kernel/apic/apic.c|   48 ++--
 arch/x86/kernel/apic/apic_flat_64.c|5 +-
 arch/x86/kernel/apic/bigsmp_32.c   |8 +-
 arch/x86/kernel/apic/es7000_32.c   |   12 +-
 arch/x86/kernel/apic/io_apic.c |  239 ++--
 arch/x86/kernel/apic/nmi.c |   29 +-
 arch/x86/kernel/apic/numaq_32.c|   53 ++--
 arch/x86/kernel/apic/probe_32.c|   18 +-
 arch/x86/kernel/apic/probe_64.c|8 +-
 arch/x86/kernel/apic/summit_32.c   |   23 +-
 arch/x86/kernel/apic/x2apic_uv_x.c |   26 +-
 arch/x86/kernel/cpu/addon_cpuid_features.c |9 +-
 arch/x86/kernel/cpu/amd.c  |   26 +-
 arch/x86/kernel/cpu/bugs.c |   23 +-
 arch/x86/kernel/cpu/bugs_64.c  |4 +-
 arch/x86/kernel/cpu/centaur.c  |   12 +-
 arch/x86/kernel/cpu/common.c   |   54 ++--
 arch/x86/kernel/cpu/cpu_debug.c|4 +-
 arch/x86/kernel/cpu/cyrix.c|   12 +-
 arch/x86/kernel/cpu/intel.c|   14 +-
 arch/x86/kernel/cpu/intel_cacheinfo.c  |   14 +-
 arch/x86/kernel/cpu/mcheck/mce-inject.c|   20 +-
 arch/x86/kernel/cpu/mcheck/mce.c   |   59 ++--
 arch/x86/kernel/cpu/mcheck/mce_intel.c |8 +-
 arch/x86/kernel/cpu/mcheck/p5.c|   21 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c   |   21 +-
 arch/x86/kernel/cpu/mcheck/threshold.c |7 +-
 arch/x86/kernel/cpu/mcheck/winchip.c   |8 +-
 arch/x86/kernel/cpu/mtrr/centaur.c |4 +-
 arch/x86/kernel/cpu/mtrr/cleanup.c |   59 ++--
 arch/x86/kernel/cpu/mtrr/generic.c |   39 +-
 arch/x86/kernel/cpu/mtrr/main.c|   32 +-
 arch/x86/kernel/cpu/perf_event.c   |   10 +-
 arch/x86/kernel/cpu/perfctr-watchdog.c |   11 +-
 arch/x86/kernel/cpu/transmeta.c|   20 +-
 arch/x86/kernel/cpu/vmware.c   |   11 +-
 arch/x86/kernel/ftrace.c   |8 +-
 arch/x86/kernel/microcode_amd.c|5 +-
 arch/x86/kernel/microcode_core.c   |   23 +-
 arch/x86/kernel/microcode_intel.c  |   47 +--
 arch/x86/kernel/setup_percpu.c |   13 +-
 arch/x86/kvm/i8254.c   |   12 +-
 arch/x86/mm/kmmio.c|   40 +-
 arch/x86/mm/mmio-mod.c |   71 ++--
 arch/x86/mm/testmmiotrace.c|   29 +-
 crypto/algapi.c|4 +-
 crypto/ansi_cprng.c|   39 +-
 crypto/async_tx/async_tx.c |5 +-
 crypto/async_tx/raid6test.c|   30 +-
 crypto/fips.c

Re: [PATCH] Export symbol ksize()

2009-02-16 Thread Joe Perches
On Mon, 2009-02-16 at 14:56 +0100, Johannes Weiner wrote:
 One problem is that zeroing ksize()
 bytes can have an overhead of nearly twice the actual allocation size.

A possible good thing is when linux has a
mechanism to use known zeroed memory in
kzalloc or kcalloc, it's already good to go.

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [RESEND] crypto test: use print_hex_dump from linux/kernel.h instead

2007-11-26 Thread Joe Perches
On Tue, 2007-11-27 at 01:28 +0800, Denis Cheng wrote:
 -static void hexdump(unsigned char *buf, unsigned int len)
 -{
 - while (len--)
 - printk(%02x, *buf++);
 -
 - printk(\n);
 -}

#define hexdump(buf, len) \
print_hex_dump(KERN_CONT, , DUMP_PREFIX_NONE, 16, 1, \
   (buf), (len), false)

requires no other changes.


-
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html