lib: string: move strlcpy() to a common place

Move strlcpy() definition from drivers/usb/gadget/ether.c to
lib/string.c because it is a very useful function.
Let's add the prototype to include/linux/string.h too.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
dm: add a command to list devices in a tree-like format

We are adding more and more drivers to driver model these days.
Compared with the ad-hoc driver system, it seems pretty difficult to
understand how drivers are working on driver model.  For ex.
  - Which devices have been bound?
  - Which devices have been probed?
  - Which is the parent of this device?
etc.

I hope this tool will help us test/review driver model patches.

Just hit "showdev" on the command line and it will list all the bound
devices in a tree-like format with Class and Probed flag.

  => showdev
   Class       Probed   Name
  ----------------------------------------
   root        [ + ]    root_driver
   demo        [   ]    |-- demo_shape_drv
   demo        [   ]    |-- demo_simple_drv
   demo        [   ]    |-- demo_shape_drv
   demo        [   ]    |-- demo_simple_drv
   demo        [   ]    |-- demo_shape_drv
   test        [   ]    |-- test_drv
   test        [   ]    |-- test_drv
   test        [   ]    |-- test_drv
   gpio        [   ]    |-- gpio_sandbox
   serial      [   ]    |-- serial_sandbox
   serial      [ + ]    |-- serial
   demo        [   ]    |-- triangle
   demo        [   ]    |-- square
   demo        [   ]    |-- hexagon
   gpio        [   ]    |-- gpios
   i2c         [ + ]    |-- i2c@0
   i2c_eeprom  [ + ]    |   |-- eeprom@2c
   i2c_emul    [ + ]    |   |   \-- emul
   i2c_generic [ + ]    |   \-- generic_59
   spi         [   ]    |-- spi@0
   spi_emul    [   ]    |   \-- flash@0
   cros_ec     [ + ]    \-- cros-ec@0

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-cc: sjg
Cover-letter:
dm: display devices in a tree-like format for easy debug

When I was reviewing I2C DM series, I found it difficult to
track what is going on.  "When is this node is bound/probe?" etc.

I think this tool is helpful to know which device is bound/probe.

Devices are listed like "tree" command does.

END
sandbox: enable showdev command

Of course, this command can be used on any boards besides sandbox.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
replace DIV_ROUND with DIV_ROUND_CLOSEST

The Linux-compatible macro DIV_ROUND_CLOSEST is a bit more flexible
and safer than DIV_ROUND.

For example,
  foo = DIV_ROUND_CLOSEST(x, y++)
works expectedly, but
  foo = DIV_ROUND(x, y++)
does not. (y is incremented twice.)

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cover-letter:
Collect utility macros to include/linux/kernel.h synced with Linux
We have imported useful macros from Linux scattering them
to various places.

In include/common.h are min, max, min3, max3, ARRAY_SIZE, ALIGN,
container_of, DIV_ROUND_UP, roundup, etc.
In include/linux/compat.h are min_t, max_t, round_up, round_down,
etc.
We also have duplicated defines of min_t in some *.c files.

I'd like to create include/linux/kernel.h and arrange
sprinkled Linux-originated macros in order.
I believe this work will be helpful when we import more macros
or sync include/linux/kenrel.h in the future.

I confirmed clean output of buildman.

No section: 'make-flags'
boards.cfg is up to date. Nothing to do.
Summary of 7 commits for 1175 boards (8 threads, 1 job per thread)
01: arm: interrupt_init: set sp in IRQ/FIQ modes
     nios2: +   nios2-generic
        sh: +   rsk7269 rsk7264 rsk7203
  blackfin: +   bf609-ezkit
       arm: +   maxbcm smdkv310 snow smdk5250 smdk5420 origen odroid db-mv784mp-gp s5pc210_universal trats peach-pit arndale trats2
   powerpc: +   TQM834x
02: replace DIV_ROUND with DIV_ROUND_CLOSEST
03: include/common.h: remove DIV_ROUND definition
04: include: move various macros to include/linux/kernel.h
05: linux/kernel.h: import more macros
06: linux/kernel.h: add typechecking to roundup macro
07: linux/kernel.h: sync min, max, min3, max3 macros with Linux

END
include/common.h: remove DIV_ROUND definition

All the references of DIV_ROUND have been replaced with
DIV_ROUND_CLOSEST.  Remove DIV_ROUND.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
include: move various macros to include/linux/kernel.h

U-Boot has imported various utility macros from Linux
scattering them to various places without consistency.

In include/common.h are min, max, min3, max3, ARRAY_SIZE, ALIGN,
container_of, DIV_ROUND_UP, etc.
In include/linux/compat.h are min_t, max_t, round_up, round_down,
etc.
We also have duplicated defines of min_t in some *.c files.

Moreover, we are suffering from too cluttered include/common.h.

This commit moves various macros that originate in
include/linux/kernel.h of Linux to their original position.

Note:
This commit simply moves the macros; the macros roundup,
min, max, min2, max3, ARRAY_SIZE are different
from those of Linux at this point.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-version: 3
Series-changes: 3
  - Move also mult_frac
linux/kernel.h: import more macros

These macros seem to be useful for U-Boot too (or at least
harmless).  Imported from Linux 3.18-rc2.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
linux/kernel.h: add typechecking to roundup macro

This commit replaces roundup macro with the one from Linux Kernel.

DEFINE_ALIGN_BUFFER must be fixed because typechecking can not
be used in this context.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
linux/kernel.h: sync min, max, min3, max3 macros with Linux

U-Boot has never cared about the type when we get max/min of two
values, but Linux Kernel does.  This commit gets min, max, min3, max3
macros synced with the kernel introducing type checks.

Many of references of those macros must be fixed to suppress warnings.
We have two options:
 - Use min, max, min3, max3 only when the arguments have the same type
   (or add casts to the arguments)
 - Use min_t/max_t instead with the appropriate type for the first
   argument

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Pavel Machek <pavel@denx.de>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Series-changes: 2
 - Fix a typo:  s/introduing/introducing/
 - Change arch/arm/cpu/arm1176/tnetv107x/clock.c
     #define MAXPOSTDIV    8UL  seems better than adding a cast.
linux/compat.h: remove redundant defines

__user and __iomem are defined in include/linux/compiler.h
MAX_ERRNO is defined in include/linux/err.h

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Replace <compile.h> with <linux/compiler.h>

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
ARM: remove CONFIG_ARMV7 defines

Some (not all) of ARMv7 boards define CONFIG_ARMV7, which is useless.
Besides, it is never referenced.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cover-letter:
Delete CONFIG_ARM<CPU_NAME> and use CONFIG_CPU_<CPU_NAME>

Since commit 2e07c249a67e055 (kconfig: arm: introduce symbol for ARM CPUs),
every ARM board is supposed to select CONFIG_CPU_<CPU_NAME>.
(CONFIG_CPU_ARM720T, CONFIG_CPU_ARM920T, CONFIG_CPU_V7, etc.)

We no longer need CONFIG_ARM920T, CONFIG_ARMV7, etc.
These macros have been defined inconsistently.
For example, some ARMv7 boards define CONFIG_ARMV7 in header files,
but some ARMv7 boards do not.
Macros defines based on a whim seems useless.

Going forward, let's use CONFIG_CPU_*.

I built all the ARM boards and compared MD5SUM.
I confirmed all the checksum matched with/without this series,
so I am sure this series does not change the output binaries at all.

END
ARM: remove CONFIG_ARM1176 defines

CONFIG_ARM1176 is defined for some boards but not referenced at all.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
ARM: remove CONFIG_ARM920T defines

CONFIG_CPU_ARM920T was introduced into Kconfig by commit 2e07c249a67e
(kconfig: arm: introduce symbol for ARM CPUs).

This commit removes all the defines of CONFIG_ARM920T and replaces the
only reference in drivers/usb/host/ohci-hcd.c with CONFIG_CPU_ARM920T.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
ARM: remove CONFIG_ARM926EJS defines

CONFIG_CPU_ARM926EJS was introduced into Kconfig by commit 2e07c249a67e
(kconfig: arm: introduce symbol for ARM CPUs).

This commit removes all the defines of CONFIG_ARM926EJS and replaces
the only reference in arch/arm/lib/cache.c with CONFIG_CPU_ARM926EJS.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
ARM: remove CONFIG_ARM1136 defines

CONFIG_CPU_ARM1136 was introduced into Kconfig by commit 2e07c249a67e
(kconfig: arm: introduce symbol for ARM CPUs).

This commit removes all the defines of CONFIG_ARM1136 and replaces
the only reference in arch/arm/lib/cache.c with CONFIG_CPU_ARM1136.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
kbuild: Descend into SOC directory from CPU directory

Some CPUs of some architectures have SOC directories.
At present, the build system directly descends into SOC directories
from the top Makefile, but it should generally descend into each
directory from its parent directory.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cover-letter:
kbuild: descend into SOC directory from CPU directory

In Kbuild, the build system generally descends into each directory
from its parent directory, but SOC directory is one of the rule
violations.

My motivation of this series is to make further refactoring possible.

You might perhaps wonder if the build system works equivalently
especially with 3/4.

I built all the boards to confirm that no boards are broken.
Moreover, 2/4 thru 4/4 do not change anything, i.e. produce the same
binaries for all the boards.
END
x86: use CONFIG_SYS_COREBOOT to descend into coreboot/ directory

The references of CONFIG_SYS_COREBOOT in arch/x86/cpu/coreboot/Makefile
are redundant because the build system descends into the directory
only when CONFIG_SYS_COREBOOT is defined.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Simon Glass <sjg@chromium.org>
kbuild: use SoC-specific CONFIG to descend into SoC directory

Use "obj-$(CONFIG_FOO) += foo/" where it is possible.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
tegra: do not descend into empty directories

Some tegra makefiles only contain a dummy line to generate
a built-in.o.  Let's do not descend into such directories.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Warren <twarren@nvidia.com>
Cc: Stephen Warren <swarren@nvidia.com>