[bootlin/training-materials updates] master: Kernel serial lab: devm_ioremap_resource doesn't return NULL in case of error (96a4dc1b)

Gregory CLEMENT gregory.clement at bootlin.com
Wed Jan 20 14:43:37 CET 2021

Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/96a4dc1bf7897da62d7d3c634eac579af857f91d


commit 96a4dc1bf7897da62d7d3c634eac579af857f91d
Author: Gregory CLEMENT <gregory.clement at bootlin.com>
Date:   Wed Jan 20 14:43:37 2021 +0100

    Kernel serial lab: devm_ioremap_resource doesn't return NULL in case of error
    The macro IS_ERR and PTR_ERR must be use to manage the return value of
    Make the example code closer to our solution.
    Signed-off-by: Gregory CLEMENT <gregory.clement at bootlin.com>


 labs/kernel-serial-iomem/kernel-serial-iomem.tex | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/labs/kernel-serial-iomem/kernel-serial-iomem.tex b/labs/kernel-serial-iomem/kernel-serial-iomem.tex
index 11a85ed9..ae06c71e 100644
--- a/labs/kernel-serial-iomem/kernel-serial-iomem.tex
+++ b/labs/kernel-serial-iomem/kernel-serial-iomem.tex
@@ -152,20 +152,14 @@ address, by calling:
 dev->regs = devm_ioremap_resource(&pdev->dev, res);
-if (!dev->regs) {
-        dev_err(&pdev->dev, "Cannot remap registers\n");
-        return -ENOMEM;
+if (IS_ERR(dev->regs))
+        return PTR_ERR(dev->regs);
 What's nice is that you won't ever have to release this resource,
 neither in the \code{remove()} routine, nor if there are failures
 in subsequent steps of the \code{probe()} routine.
-We haven't explained the \code{dev_*} logging routines yet.
-Before further explanations, they are basically used to tell which
-device a given log message is associated to. 
 Make sure that your updated driver compiles, loads and unloads well.
 \section{Device initialization}

More information about the training-materials-updates mailing list