[PATCH 06/19] lib/genalloc.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
Removing this include produces byte-identical output, and thus removes a false dependency. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/genalloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/genalloc.c b/lib/genalloc.c index 2e65d206b01c..17d8f58f6716 100644

[PATCH 19/19] lib/lcm.c: Replace include

2014-12-30 Thread Rasmus Villemoes
We don't need all the stuff kernel.h pulls in; just compiler.h since export.h doesn't do necessary #includes. This removes more than 100 dependencies. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/lcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib

[PATCH 16/19] lib/stmp_device.c: Replace module.h include

2014-12-30 Thread Rasmus Villemoes
stmp_device.c only needs EXPORT_SYMBOL, so just include compiler.h and export.h instead of the whole module.h machinery. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/stmp_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stmp_device.c b/lib

[PATCH 17/19] lib/strncpy_from_user.c: Replace module.h include

2014-12-30 Thread Rasmus Villemoes
strncpy_from_user.c only needs EXPORT_SYMBOL, so just include compiler.h and export.h instead of the whole module.h machinery. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/strncpy_from_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib

[PATCH 10/19] lib/kobject_uevent.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
The file doesn't seem to use anything from linux/user_namespace.h, and removing it yields byte-identical object code and strictly fewer dependencies in the .cmd file. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/kobject_uevent.c | 1 - 1 file changed, 1 deletion(-) diff

[PATCH 18/19] lib/percpu_ida.c: Remove redundant includes

2014-12-30 Thread Rasmus Villemoes
. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/percpu_ida.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c index 93d145e5539c..f75715131f20 100644 --- a/lib/percpu_ida.c +++ b/lib/percpu_ida.c @@ -19,13 +19,10 @@ #include linux/bug.h

[PATCH 12/19] lib/plist.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
Removing the include of linux/spinlock.h produces byte-identical output for {allno,def}config, and identical objdump -d output for allyesconfig. In the former two cases, more than a 100 lines are eliminated from the generated dependency file. Signed-off-by: Rasmus Villemoes li

[PATCH 13/19] lib/radix-tree.c: Change to simpler include

2014-12-30 Thread Rasmus Villemoes
The comment helpfully explains why hardirq.h is included, but since 2d4b84739f0a (hardirq: Split preempt count mask definitions) in_interrupt() has been provided by preempt_mask.h. Use that instead, saving around 40 lines in the generated dependency file. Signed-off-by: Rasmus Villemoes li

[PATCH 14/19] lib/show_mem.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
show_mem.c doesn't use anything from nmi.h. Removing it yields identical objdump -d output for each of {allyes,allno,def}config and eliminates more than 100 lines in the dependency file. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/show_mem.c | 1 - 1 file changed, 1 deletion

[PATCH 11/19] lib/nlattr.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
nlattr.c doesn't seem to rely on anything from netdevice.h. Removing it yields identical objdump -d output for each of {allyes,allno,def}config, and eliminates more than 200 lines from the generated dependency file. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/nlattr.c | 1

[PATCH 05/19] lib/idr.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
idr.c doesn't seem to use anything from hardirq.h (or anything included from that). Removing it produces identical objdump -d output, and gives 44 fewer lines in the .idr.o.cmd dependency file. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/idr.c | 1 - 1 file changed, 1

[PATCH 09/19] lib/llist.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
This file doesn't seem to use anything provided by linux/interrupt.h or anything recursively included through that. Removing it produces byte-identical output, while reducing .llist.o.cmd from 541 to 156 lines. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/llist.c | 1 - 1

[PATCH 08/19] lib/md5.c: Simplify include

2014-12-30 Thread Rasmus Villemoes
md5.c doesn't use anything from kernel.h, except that that pulls in compiler.h, which is needed for the export.h to work. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/md5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/md5.c b/lib/md5.c index

[PATCH 02/19] lib/sort.c: Use simpler includes

2014-12-30 Thread Rasmus Villemoes
.sort.o.cmd. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/sort.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sort.c b/lib/sort.c index 926d00429ed2..14fc1dfadb3f 100644 --- a/lib/sort.c +++ b/lib/sort.c @@ -4,8 +4,8 @@ * Jan 23 2005 Matt Mackall m

[PATCH 07/19] lib/list_sort.c: Rearrange includes

2014-12-30 Thread Rasmus Villemoes
, but only if !CONFIG_DYNAMIC_DEBUG, so just include it explicitly (for memset). objdump -d says the generated code is the same, and wc -l says that lib/.list_sort.o.cmd went from 579 to 165 lines. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/list_sort.c | 7 +-- 1 file

[PATCH 04/19] lib/halfmd4.c: Simplify includes

2014-12-30 Thread Rasmus Villemoes
/types.h in order for gcc not to complain about unknown types. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/cryptohash.h | 2 ++ lib/halfmd4.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/cryptohash.h b/include/linux

[PATCH 01/19] lib/interval_tree.c: Simplify includes

2014-12-30 Thread Rasmus Villemoes
The file uses nothing from init.h, and also doesn't need the full module.h machinery; export.h is sufficient. The latter requires the user to ensure compiler.h is included, so do that explicitly instead of relying on some other header pulling it in. Signed-off-by: Rasmus Villemoes li

[PATCH 00/19] lib: Some #include cleanups

2014-12-30 Thread Rasmus Villemoes
files, but that is of course at the same time a huge can of worms, involving boatloads of tree-wide patches updating users to include what they use directly. So before I start doing that, I'd like to hear if people think it would be futile. Rasmus Villemoes (19): lib/interval_tree.c: Simplify

[PATCH 03/19] lib/dynamic_queue_limits.c: Simplify includes

2014-12-30 Thread Rasmus Villemoes
The file doesn't use anything from ctype.h. Instead of module.h, just use export.h for EXPORT_SYMBOL. The latter requires the user to include compiler.h, so do that explicitly instead of relying on some other header pulling it in. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib

[PATCH 1/2] lib/bitmap.c: Change prototype of bitmap_copy_le

2014-12-30 Thread Rasmus Villemoes
their u8 or __le32 buffers without a cast. Furthermore, this allows us to simply let bitmap_copy_le be an alias for bitmap_copy on little-endian; see next patch. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 2 +- lib/bitmap.c | 9 - 2

[PATCH 2/2] lib/bitmap.c: Elide bitmap_copy_le on little-endian

2014-12-30 Thread Rasmus Villemoes
On little-endian, there's no reason to have an extra, presumably less efficient, way of copying a bitmap. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 4 lib/bitmap.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/linux

[PATCH] lib: Remove strnicmp

2014-12-11 Thread Rasmus Villemoes
Now that all in-tree users of strnicmp have been converted to strncasecmp, the wrapper can be removed. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: For 3.20. The #undef __HAVE_ARCH_STRNICMP in arch/s390/include/asm/string.h is a no-op, so removing

[PATCH 0/8] lib: bitmap: Another small series

2014-12-11 Thread Rasmus Villemoes
I found some patches in a long-forgotten branch - they still applied cleanly, so I spiced them up with a few extra simplifications and signed-unsigned conversions. Rasmus Villemoes (8): lib: bitmap: More signed-unsigned conversions linux/nodemask.h: Update bitmap wrappers to take unsigned int

[PATCH 1/8] lib: bitmap: More signed-unsigned conversions

2014-12-11 Thread Rasmus Villemoes
For consistency with the other bitmap_* functions, also make the nbits parameter of bitmap_zero, bitmap_fill and bitmap_copy unsigned. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff

[PATCH 8/8] lib: bitmap: Minor changes of bitmap_remap

2014-12-11 Thread Rasmus Villemoes
Make the nbits parameter unsigned for consistency with most other bitmap_* functions, and pull the test of empty dst out of the loop. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 2 +- lib/bitmap.c | 23 ++- 2 files changed

[PATCH 5/8] lib: bitmap: Change parameters of bitmap_fold to unsigned

2014-12-11 Thread Rasmus Villemoes
Change the sz and nbits parameters of bitmap_fold to unsigned int for consistency with other bitmap_* functions, and to save another few bytes in the generated code. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 2 +- lib/bitmap.c | 8 2

[PATCH 6/8] lib: bitmap: Simplify bitmap_pos_to_ord

2014-12-11 Thread Rasmus Villemoes
of bitmap_pos_to_ord. Since the static inline frontend bitmap_weight doesn't handle nbits==0 correctly (it would behave exactly as if nbits==BITS_PER_LONG), use __bitmap_weight. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: Alternatively, the last line could be spelled bitmap_weight

[PATCH 4/8] lib: bitmap: Update bitmap_onto to unsigned

2014-12-11 Thread Rasmus Villemoes
Change the nbits parameter of bitmap_onto to unsigned int for consistency with other bitmap_* functions. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 2 +- lib/bitmap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH 7/8] lib: bitmap: Simplify bitmap_ord_to_pos

2014-12-11 Thread Rasmus Villemoes
(unofficial) 0. No current users are affected by this change. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 2 +- lib/bitmap.c | 28 +++- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/include/linux

[PATCH 3/8] linux/cpumask.h: Update bitmap wrappers to take unsigned int

2014-12-11 Thread Rasmus Villemoes
Since the various bitmap_* functions now take an unsigned int as nbits parameter, it makes sense to also update the various wrappers, even though they're marked as obsolete. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/cpumask.h | 22 +++--- 1 file

[PATCH 2/8] linux/nodemask.h: Update bitmap wrappers to take unsigned int

2014-12-11 Thread Rasmus Villemoes
Since the various bitmap_* functions now take an unsigned int as nbits parameter, it makes sense to also update the various wrappers. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/nodemask.h | 26 +- 1 file changed, 13 insertions(+), 13

[PATCH 2/3] staging: unisys: remove leftover __DATE__

2014-12-12 Thread Rasmus Villemoes
Commit 836bee9eee6d (Staging: unisys: remove references to __DATE__ and __TIME__) removed most; this seems to be an accidental leftover. VERSIONDATE is not used anywhere. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/staging/unisys/common-spar/include/version.h | 1 - 1

[PATCH 1/3] checkpatch: Check for use of disallowed macros

2014-12-12 Thread Rasmus Villemoes
Since fe7c36c7 (Makefile: Build with -Werror=date-time if the compiler supports it), use of __DATE__, __TIME__, __TIMESTAMP__ has been disallowed. This hasn't prevented a few new users from creeping in. Make checkpatch complain. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk

[PATCH 3/3] ACPICA: Remove use of __DATE__ macro

2014-12-12 Thread Rasmus Villemoes
The macro __DATE__ and friends is not allowed in the kernel. Also, including the build time in output doesn't seem to provide any value. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/acpi/acpica/acapps.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff

Re: [PATCH] ASoC: soc-dapm: Fix comparison of pointers

2014-12-12 Thread Rasmus Villemoes
On Fri, Dec 12 2014, Mark Brown broo...@kernel.org wrote: On Tue, Dec 09, 2014 at 10:53:41PM +0100, Rasmus Villemoes wrote: if (a-reg != b-reg) return a-reg - b-reg; -if (a-dapm != b-dapm) -return (unsigned long)a-dapm - (unsigned long)b-dapm

[PATCH 3/3] lib: string_get_size: Return void

2014-12-12 Thread Rasmus Villemoes
string_get_size was documented to return an error, but in fact always returned 0. Since the output always fits in 9 bytes, just document that and let callers do what they do now: Pass a small stack buffer and ignore the return value. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk

[PATCH 2/3] lib: string_get_size: Use 32 bit arithmetic when possible

2014-12-12 Thread Rasmus Villemoes
replace a do_div with an ordinary 32/32 bit division. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/string_helpers.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 0d25f7aa732c..2b3757f84b3b 100644

[PATCH 1/3] lib: string_get_size: Remove redundant prefixes

2014-12-12 Thread Rasmus Villemoes
sentinel; once we reach E size is at most 18. [The test is also wrong; it should be units_str[units][i+1]; if we've reached NULL we're already doomed.] Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/string_helpers.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff

[PATCH v2 0/3] trace: Use simpler seq_file functions

2014-11-08 Thread Rasmus Villemoes
lines. Rasmus Villemoes (3): trace: Replace seq_printf by simpler equivalents trace: Merge consecutive seq_puts calls trace: Replace single-character seq_puts with seq_putc kernel/trace/ftrace.c| 30 +++--- kernel/trace/trace.c | 78

[PATCH v2 2/3] trace: Merge consecutive seq_puts calls

2014-11-08 Thread Rasmus Villemoes
Consecutive seq_puts calls with literal strings can be merged to a single call. This reduces the size of the generated code, and can also lead to slight .rodata reduction (because of fewer nul and padding bytes). It should also shave a off a few clock cycles. Signed-off-by: Rasmus Villemoes li

[PATCH v2 1/3] trace: Replace seq_printf by simpler equivalents

2014-11-08 Thread Rasmus Villemoes
will simplify further. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- kernel/trace/ftrace.c| 30 kernel/trace/trace.c | 44 ++-- kernel/trace/trace_branch.c | 26

[PATCH v2 3/3] trace: Replace single-character seq_puts with seq_putc

2014-11-08 Thread Rasmus Villemoes
Printing a single character to a seqfile might as well be done with seq_putc instead of seq_puts; this avoids a strlen() call and a memory access. It also shaves another few bytes off the generated code. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- kernel/trace/ftrace.c

[PATCH v2 4/6] scsi: misc: Replace seq_printf with seq_puts

2014-12-02 Thread Rasmus Villemoes
Using seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists. Replace seq_printf with seq_puts when possible. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/BusLogic.c | 10 +- drivers/scsi/NCR5380.c

[PATCH v2 6/6] scsi: misc: Print single-character strings with seq_putc

2014-12-02 Thread Rasmus Villemoes
Using seq_putc to print a single character saves at least a strlen() call and a memory access, and may also give a small .text reduction. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/advansys.c | 34

[PATCH v2 1/6] scsi: Remove SPRINTF macro

2014-12-02 Thread Rasmus Villemoes
The macro SPRINTF doesn't save a lot of typing or make the code more readable, and depending on a specific identifier (m) in the surrounding scope is generally frowned upon. Nuke it. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/NCR5380.c | 20 ++- drivers/scsi

[PATCH v2 5/6] scsi: misc: Merge consecutive seq_puts calls

2014-12-02 Thread Rasmus Villemoes
Consecutive seq_puts calls with literal strings may be replaced by a single call, saving a little .text. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/advansys.c | 43 +++ drivers/scsi/atp870u.c | 5 ++--- drivers

[PATCH v2 2/6] scsi/advansys: Replace seq_printf with seq_puts

2014-12-02 Thread Rasmus Villemoes
Using seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists. Replace seq_printf with seq_puts when possible. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/advansys.c | 155

[PATCH v2 3/6] scsi/aha152x: Replace seq_printf with seq_puts

2014-12-02 Thread Rasmus Villemoes
Using seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists. Replace seq_printf with seq_puts when possible. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/aha152x.c | 248

[PATCH v2 0/6] scsi: Some seq_file cleanups/optimizations

2014-12-02 Thread Rasmus Villemoes
the semantics of the code (well, that's the idea anyway), but should make it slightly smaller and faster. v2: Redone on top of git://git.infradead.org/users/hch/scsi-queue.git drivers-for-3.19 Rasmus Villemoes (6): scsi: Remove SPRINTF macro scsi/advansys: Replace seq_printf with seq_puts scsi

Re: [PATCH 1/3] checkpatch: Check for use of disallowed macros

2014-12-18 Thread Rasmus Villemoes
On Fri, Dec 12 2014, Joe Perches j...@perches.com wrote: On Fri, 2014-12-12 at 11:51 +0100, Rasmus Villemoes wrote: Since fe7c36c7 (Makefile: Build with -Werror=date-time if the compiler supports it), use of __DATE__, __TIME__, __TIMESTAMP__ has been disallowed. This hasn't prevented a few

[PATCH 8/8 v2] lib: bitmap: Make the bits parameter of bitmap_remap unsigned

2014-12-18 Thread Rasmus Villemoes
... and rename it to nbits, both for consistency with other bitmap_* functions. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- This is meant to replace 8/8 (lib: bitmap: Minor changes of bitmap_remap), if you haven't gotten to that yet. No big deal either way. v2: Only do

[PATCH v3] lib: bitmap: Make the bits parameter of bitmap_remap unsigned

2014-12-19 Thread Rasmus Villemoes
Also, rename bits to nbits. Both changes for consistency with other bitmap_* functions. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: v3: Hopefully complete and unambiguous commit log. v2: Only do the signed-unsigned conversion. bitmap_remap only has

krealloc in kernel/params.c

2014-10-14 Thread Rasmus Villemoes
It is likely that I'm just missing something trivial, but I have a hard time understanding 63662139e (params: Fix potential memory leak in add_sysfs_param()). [I take it for granted that krealloc() does not free its first argument when it fails, as reading mm/slab_common.c seems to confirm.] Some

Re: [PATCH v3] bitops: Fix shift overflow in GENMASK macros

2014-11-05 Thread Rasmus Villemoes
On Tue, Nov 04 2014, Maxime COQUELIN maxime.coque...@st.com wrote: -#define GENMASK(h, l)(((U32_C(1) ((h) - (l) + 1)) - 1) (l)) -#define GENMASK_ULL(h, l)(((U64_C(1) ((h) - (l) + 1)) - 1) (l)) +#define GENMASK(h, l) \ + ((~0UL (BITS_PER_LONG - ((h) - (l) + 1)))

[PATCH] include/linux/socket.h: Fix comment

2014-11-05 Thread Rasmus Villemoes
File descriptors are always closed on exit :-) Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/socket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/socket.h b/include/linux/socket.h index ec538fc..bb9b836 100644 --- a/include/linux

Re: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents

2014-11-05 Thread Rasmus Villemoes
On Wed, Nov 05 2014, Steven Rostedt rost...@goodmis.org wrote: On Fri, 12 Sep 2014 11:25:52 +0200 Rasmus Villemoes li...@rasmusvillemoes.dk wrote: diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 5916a8e..7b9ce28 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace

[PATCH] usb: musb: Fix a few off-by-one lengths

2014-11-27 Thread Rasmus Villemoes
change the other occurences of the !strncmp idiom. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Strictly speaking this is a user-visible change since buf came from userspace. I can't believe anybody cares, though. drivers/usb/musb/musb_cppi41.c | 4 ++-- drivers/usb/musb

[PATCH] drivers: ide: Fix mostly harmless off-by-one hardcoded value

2014-11-27 Thread Rasmus Villemoes
The string IOMEGA Clik! has length 12, not 11. Using strstarts avoids the error-prone hardcoding of the prefix length. For consistency, also change the occurence just above. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/ide/ide-floppy.c | 4 ++-- 1 file changed, 2

[PATCH 2/7] lib: bitmap: Eliminate branch in __bitmap_shift_right

2014-11-28 Thread Rasmus Villemoes
We can shift the bits from lower and upper into place before assembling dst[k]; moving the shift of upper into the branch where we already know that rem is non-zero allows us to remove a conditional. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/bitmap.c | 6 +++--- 1 file

[PATCH 3/7] lib: bitmap: Remove redundant code from __bitmap_shift_right

2014-11-28 Thread Rasmus Villemoes
-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/bitmap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/bitmap.c b/lib/bitmap.c index 9250c3f..20bb314 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -134,8 +134,6 @@ void __bitmap_shift_right(unsigned long *dst, const unsigned

[PATCH 1/7] lib: bitmap: Change bitmap_shift_right to take unsigned parameters

2014-11-28 Thread Rasmus Villemoes
is 0 the loop is never executed. Also use shift and nbits consistently for the parameter names. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 12 ++-- lib/bitmap.c | 10 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff

[PATCH 0/7] lib: bitmap: Simplify bitmap_shift_{left,right}

2014-11-28 Thread Rasmus Villemoes
from being wrong before, though. Rasmus Villemoes (7): lib: bitmap: Change bitmap_shift_right to take unsigned parameters lib: bitmap: Eliminate branch in __bitmap_shift_right lib: bitmap: Remove redundant code from __bitmap_shift_right lib: bitmap: Yet another simplification

[PATCH 5/7] lib: bitmap: Change bitmap_shift_left to take unsigned parameters

2014-11-28 Thread Rasmus Villemoes
and nbits consistently for the parameter names. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- include/linux/bitmap.h | 12 ++-- lib/bitmap.c | 11 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux

[PATCH 7/7] lib: bitmap: Remove redundant code from __bitmap_shift_left

2014-11-28 Thread Rasmus Villemoes
-order don't care bits of dst, about which no guarantee is made. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/bitmap.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/bitmap.c b/lib/bitmap.c index 2362601..acea8ae 100644 --- a/lib/bitmap.c +++ b

[PATCH 6/7] lib: bitmap: Eliminate branch in __bitmap_shift_left

2014-11-28 Thread Rasmus Villemoes
We can shift the bits from lower and upper into place before assembling dst[k + off]; moving the shift of lower into the branch where we already know that rem is non-zero allows us to remove a conditional. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/bitmap.c | 7 +++ 1

[PATCH 4/7] lib: bitmap: Yet another simplification in __bitmap_shift_right

2014-11-28 Thread Rasmus Villemoes
If left is 0, we can just let mask be ~0UL, so that anding with it is a no-op. Conveniently, BITMAP_LAST_WORD_MASK provides precisely what we need, and we can eliminate left. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/bitmap.c | 8 1 file changed, 4 insertions

[PATCH 2/2] x86: Merge consecutive seq_puts calls

2014-11-28 Thread Rasmus Villemoes
These can be done as a single seq_puts call, reducing the code size slightly. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- arch/x86/platform/uv/tlb_uv.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch

[PATCH 1/2] x86: Replace seq_printf with seq_puts

2014-11-28 Thread Rasmus Villemoes
seq_puts is a lot cheaper than seq_printf, so use that to print literal strings. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- arch/x86/kernel/cpu/proc.c| 10 +- arch/x86/kernel/irq.c | 30 +++--- arch/x86/mm/pat.c | 2

[PATCH 0/7] scsi: Some seq_file cleanups/optimizations

2014-11-28 Thread Rasmus Villemoes
obfuscating, macros. The patches don't change the semantics of the code (well, that's the idea anyway), but should make it slightly smaller and faster. Rasmus Villemoes (7): scsi: Remove SPRINTF macro scsi/g_NCR5380: Remove obfuscating macros scsi/advansys: Replace seq_printf with seq_puts scsi

[PATCH 1/7] scsi: Remove SPRINTF macro

2014-11-28 Thread Rasmus Villemoes
The macro SPRINTF doesn't save a lot of typing or make the code more readable, and depending on a specific identifier (m) in the surrounding scope is generally frowned upon. Nuke it. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/NCR5380.c | 42 +++--- drivers

[PATCH 6/7] scsi: misc: Merge consecutive seq_puts calls

2014-11-28 Thread Rasmus Villemoes
Consecutive seq_puts calls with literal strings may be replaced by a single call, saving a little .text. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/advansys.c | 40 ++-- drivers/scsi/atp870u.c | 5 ++--- drivers/scsi

[PATCH 7/7] scsi: misc: Print single-character strings with seq_putc

2014-11-28 Thread Rasmus Villemoes
Using seq_putc to print a single character saves at least a strlen() call and a memory access, and may also give a small .text reduction. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/advansys.c | 34

[PATCH 3/7] scsi/advansys: Replace seq_printf with seq_puts

2014-11-28 Thread Rasmus Villemoes
Using seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists. Replace seq_printf with seq_puts when possible. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/advansys.c | 157

[PATCH 5/7] scsi: misc: Replace seq_printf with seq_puts

2014-11-28 Thread Rasmus Villemoes
Using seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists. Replace seq_printf with seq_puts when possible. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/BusLogic.c | 10 +- drivers/scsi/NCR5380.c

[PATCH 4/7] scsi/aha152x: Replace seq_printf with seq_puts

2014-11-28 Thread Rasmus Villemoes
Using seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists. Replace seq_printf with seq_puts when possible. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/aha152x.c | 252

[PATCH 2/7] scsi/g_NCR5380: Remove obfuscating macros

2014-11-28 Thread Rasmus Villemoes
The macros PRINTP/ANDP make the code harder to read and depend on a specific identifier name in the surrounding scope. Nuke them. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/scsi/g_NCR5380.c | 66 ++-- 1 file changed, 30

[PATCH] net: tulip: Remove private strncmp

2014-12-04 Thread Rasmus Villemoes
a memcmp (except for the signature and that bytes are not necessarily treated as unsigned char); since only the boolean value of the result is used we can just replace de4x5_strncmp with memcmp. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: I don't know if the comment

[PATCH] fs: nfsd: Fix bug in compare_blob

2014-12-04 Thread Rasmus Villemoes
long)o2-len; but I'd rather eliminate the usually broken 'return a - b;' idiom. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: How this could ever have worked is beyond me - compare_blob seems to be used to maintain an rbtree, and I wouldn't expect rbtrees to behave

[PATCH] kernfs: Fix kernfs_name_compare

2014-12-04 Thread Rasmus Villemoes
returning hash - kn-hash in the first place is only ok because the hashes are restricted to 31 bits, add a comment explaining that. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- fs/kernfs/dir.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs

[PATCH v2] fs: nfsd: Fix signedness bug in compare_blob

2014-12-05 Thread Rasmus Villemoes
long)o2-len; but I'd rather eliminate the usually broken 'return a - b;' idiom. Reviewed-by: Jeff Layton jlay...@primarydata.com Cc: sta...@vger.kernel.org Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: How this could ever have worked is beyond me - compare_blob seems

[PATCH v2] kernfs: Fix kernfs_name_compare

2014-12-05 Thread Rasmus Villemoes
reporting a match to the caller. Technically 'hash - kn-hash' is ok since the hashes are restricted to 31 bits, but it's better to avoid that subtlety. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: v2: Also use explicit comparisons of the hashes. fs/kernfs/dir.c | 12

[PATCH 1/2] MPILIB: Fix comparison of negative MPIs

2014-12-05 Thread Rasmus Villemoes
If u and v both represent negative integers and their limb counts happen to differ, mpi_cmp will always return a positive value - this is obviously bogus. u is smaller than v if and only if it is larger in absolute value. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/mpi/mpi

[PATCH 2/2] MPILIB: Deobfuscate mpi_cmp

2014-12-05 Thread Rasmus Villemoes
mpihelp_cmp returns {-1,0,1}; -INT_MIN==INT_MIN won't bite us. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/mpi/mpi-cmp.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/mpi/mpi-cmp.c b/lib/mpi/mpi-cmp.c index 3801694240d8..d25e9e96c310 100644 --- a/lib

Re: [PATCH 3/20] PCI: fix misspelling of current function in string

2014-12-07 Thread Rasmus Villemoes
On Sun, Dec 07 2014, Julia Lawall julia.law...@lip6.fr wrote: Replace a misspelled function name by %s and then __func__. The function name begins with pci, not cpci. ... result = cpci_hotplug_init(debug); if (result) { - err(cpci_hotplug_init with error %d\n,

[PATCH] drm/i915: Fix comparison bug

2014-12-07 Thread Rasmus Villemoes
-stolen-start has type unsigned long; relying on the difference (effectively cast to int) for sorting is wrong. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- drivers/gpu/drm/i915/i915_debugfs.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu

[PATCH 1/2] lib/lcm.c: Ensure correct result whenever it fits

2014-12-09 Thread Rasmus Villemoes
Ensure that lcm(a,b) returns the mathematically correct result, provided it fits in an unsigned long. The current version returns garbage if a*b overflows, even if the final result would fit. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/lcm.c | 2 +- 1 file changed, 1

[PATCH 2/2] lib/lcm.c: lcm(n,0)=lcm(0,n) is 0, not n

2014-12-09 Thread Rasmus Villemoes
Return the mathematically correct answer when an argument is 0. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- lib/lcm.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/lcm.c b/lib/lcm.c index 01b3aa922dda..51cc6b13cd52 100644 --- a/lib/lcm.c +++ b/lib

[PATCH] ASoC: soc-dapm: Fix comparison of pointers

2014-12-09 Thread Rasmus Villemoes
The idiom 'return a - b;' often used in comparison functions is wrong unless one is certain the values being compared lie in a sufficiently small range. In this case dapm_seq_compare would also return 0 if the -dapm pointers happened to differ by a multiple of 2^32. Signed-off-by: Rasmus

[PATCH] fs: hfs: Fix comparison bug in hfs_cat_keycmp

2014-12-10 Thread Rasmus Villemoes
than a. One can also easily find three values a,b,c such that a compares less than b, b compares less than c, but a does not compare less than c. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- fs/hfs/catalog.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff

[PATCH] kernel.h: Remove ancient __FUNCTION__ hack

2015-02-04 Thread Rasmus Villemoes
__FUNCTION__ hasn't been treated as a string literal since gcc 3.4, so this only helps people who only test-compile using 3.3 (compiler-gcc3.h barks at anything older than that). Besides, there are almost no occurrences of __FUNCTION__ left in the tree. Signed-off-by: Rasmus Villemoes li

Re: [PATCH] kernel.h: Remove ancient __FUNCTION__ hack

2015-02-04 Thread Rasmus Villemoes
On Wed, Feb 04 2015, Joe Perches j...@perches.com wrote: On Wed, 2015-02-04 at 10:48 +0100, Rasmus Villemoes wrote: __FUNCTION__ hasn't been treated as a string literal since gcc 3.4, so this only helps people who only test-compile using 3.3 (compiler-gcc3.h barks at anything older than

Re: [PATCH] kernel.h: Remove ancient __FUNCTION__ hack

2015-02-04 Thread Rasmus Villemoes
On Wed, Feb 04 2015, Joe Perches j...@perches.com wrote: On Wed, 2015-02-04 at 21:55 +0100, Rasmus Villemoes wrote: On Wed, Feb 04 2015, Joe Perches j...@perches.com wrote: On Wed, 2015-02-04 at 10:48 +0100, Rasmus Villemoes wrote: __FUNCTION__ hasn't been treated as a string literal

[PATCH 5/5] kernel/cpuset.c: Mark cpuset_init_current_mems_allowed as __init

2015-02-02 Thread Rasmus Villemoes
The only caller of cpuset_init_current_mems_allowed is the __init annotated build_all_zonelists_init, so we can also make the former __init. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- kernel/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel

[PATCH 3/5] mm/mm_init.c: Mark mminit_verify_zonelist as __init

2015-02-02 Thread Rasmus Villemoes
The only caller of mminit_verify_zonelist is build_all_zonelists_init, which is annotated with __init, so it should be safe to also mark the former as __init, saving ~400 bytes of .text. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- mm/mm_init.c | 2 +- 1 file changed, 1 insertion

[PATCH 1/5] mm/internal.h: Don't split printk call in two

2015-02-02 Thread Rasmus Villemoes
All users of mminit_dprintk pass a compile-time constant as level, so this just makes gcc emit a single printk call instead of two. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- Notes: Not a huge deal, since the only users are __init or __meminit functions, but even

[PATCH 2/5] mm/page_alloc.c: Pull out init code from build_all_zonelists

2015-02-02 Thread Rasmus Villemoes
Pulling the code protected by if (system_state == SYSTEM_BOOTING) into its own helper allows us to shrink .text a little. This relies on build_all_zonelists already having a __ref annotation. Add a comment explaining why so one doesn't have to track it down through git log. Signed-off-by: Rasmus

[PATCH 0/5] mm: Some .text savings

2015-02-02 Thread Rasmus Villemoes
Only compile-tested, but I think these should be ok. Net saving aroung 450 bytes of .text. Rasmus Villemoes (5): mm/internal.h: Don't split printk call in two mm/page_alloc.c: Pull out init code from build_all_zonelists mm/mm_init.c: Mark mminit_verify_zonelist as __init mm/mm_init.c

[PATCH 4/5] mm/mm_init.c: Mark mminit_loglevel __meminitdata

2015-02-02 Thread Rasmus Villemoes
mminit_loglevel is only referenced from __init and __meminit functions, so we can mark it __meminitdata. Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk --- mm/mm_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index e17c758b27bf

Re: [PATCH v2 1/3] lib: find_*_bit reimplementation

2015-02-02 Thread Rasmus Villemoes
On Sat, Jan 31 2015, yury.no...@gmail.com wrote: From: Yury Norov y.no...@samsung.com New implementations takes less space in source file (see diffstat) and in object. For me it's 710 vs 453 bytes of text. New version generally looks good. Please include a summary of the changes between the

Re: [PATCH v2 1/3] lib: find_*_bit reimplementation

2015-02-02 Thread Rasmus Villemoes
On Mon, Feb 02 2015, George Spelvin li...@horizon.com wrote: Rasmus Villemoes li...@rasmusvillemoes.dk wrote: ... and this be part of _find_next_bit? Can find_next_bit not be simply 'return _find_next_bit(addr, size, offset, 1);', and similarly for find_next_zero_bit? Btw., passing true

<    1   2   3   4   5   6   7   8   9   10   >