mtd: orion_nand: fix error code path in probe
authorMichael Opdenacker <michael.opdenacker@free-electrons.com>
Thu, 16 Oct 2014 04:58:35 +0000 (06:58 +0200)
committerBrian Norris <computersforpeace@gmail.com>
Wed, 22 Oct 2014 08:35:41 +0000 (01:35 -0700)
commita0fa0b66ac1ce73ff791df977b07410a6f4cd337
treeb2c7d2753fc20293174b41e63082c2550a2083e3
parent59af5c7acde3d5cbbf8fadbc81a352a892cbc34c
mtd: orion_nand: fix error code path in probe

This replaces kzalloc() and ioremap() calls by devm_ functions
in the probe() routine, which automatically release the corresponding
resources when probe() fails or when the device is removed.

This simplifies simplifies the error management code, and brings
the below improvements or changes:

A. Fixing a bug reported by "make coccicheck":

If "board = devm_kzalloc()" fails, the probe() function jumps
incorrectly to label "no_res" and therefore returns without
running iounmap().

B. Requesting the memory region

Using devm_ioremap_resource() makes the probe() function request
the corresponding memory region before running ioremap(), as
it is supposed to do.

C. Standardizing the error codes:

The use of devm_ioremap_resource() changes the return value:
 * -ENOMEM instead of -EIO in case of ioremap() failure,
 * -EINVAL instead of -ENODEV in case of platform_get_resource()
   failure.

Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/orion_nand.c