ASoC: SigmaDSP: Provide diagnostic error messages
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 28 Nov 2011 08:44:18 +0000 (09:44 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 29 Nov 2011 12:01:14 +0000 (12:01 +0000)
Provide some error messages when loading the firmware fails, so it is possible
to diagnose the reason for the failure.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/sigmadsp.c

index acb97a9834aae1fb2660723d78822b5ba93a236a..c0ad88516f30a516ec92dc682ff20375e9194146 100644 (file)
@@ -124,18 +124,25 @@ int process_sigma_firmware(struct i2c_client *client, const char *name)
         * purposes and having the limit makes it easier to avoid integer
         * overflows later in the loading process.
         */
-       if (fw->size < sizeof(*ssfw_head) || fw->size >= 0x4000000)
+       if (fw->size < sizeof(*ssfw_head) || fw->size >= 0x4000000) {
+               dev_err(&client->dev, "Failed to load firmware: Invalid size\n");
                goto done;
+       }
 
        ssfw_head = (void *)fw->data;
-       if (memcmp(ssfw_head->magic, SIGMA_MAGIC, ARRAY_SIZE(ssfw_head->magic)))
+       if (memcmp(ssfw_head->magic, SIGMA_MAGIC, ARRAY_SIZE(ssfw_head->magic))) {
+               dev_err(&client->dev, "Failed to load firmware: Invalid magic\n");
                goto done;
+       }
 
        crc = crc32(0, fw->data + sizeof(*ssfw_head),
                        fw->size - sizeof(*ssfw_head));
        pr_debug("%s: crc=%x\n", __func__, crc);
-       if (crc != le32_to_cpu(ssfw_head->crc))
+       if (crc != le32_to_cpu(ssfw_head->crc)) {
+               dev_err(&client->dev, "Failed to load firmware: Wrong crc checksum: expected %x got %x\n",
+                       le32_to_cpu(ssfw_head->crc), crc);
                goto done;
+       }
 
        ssfw.pos = sizeof(*ssfw_head);