Skip to content

Commit

Permalink
USB: emi62.c: remove err() usage
Browse files Browse the repository at this point in the history
err() was a very old USB-specific macro that I thought had
gone away.  This patch removes it from being used in the
driver and uses dev_err() instead.

CC: Paul Gortmaker <paul.gortmaker@windriver.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Greg Kroah-Hartman committed Apr 20, 2012
1 parent b412284 commit e9a527d
Showing 1 changed file with 19 additions and 43 deletions.
62 changes: 19 additions & 43 deletions drivers/usb/misc/emi62.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int emi62_writememory(struct usb_device *dev, int address,
unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);

if (!buffer) {
err("emi62: kmalloc(%d) failed.", length);
dev_err(&dev->dev, "kmalloc(%d) failed.\n", length);
return -ENOMEM;
}
/* Note: usb_control_msg returns negative value on error or length of the
Expand All @@ -73,9 +73,8 @@ static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit)
dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit);

response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0);
if (response < 0) {
err("emi62: set_reset (%d) failed", reset_bit);
}
if (response < 0)
dev_err(&dev->dev, "set_reset (%d) failed\n", reset_bit);
return response;
}

Expand All @@ -87,18 +86,15 @@ static int emi62_load_firmware (struct usb_device *dev)
const struct firmware *bitstream_fw = NULL;
const struct firmware *firmware_fw = NULL;
const struct ihex_binrec *rec;
int err;
int err = -ENOMEM;
int i;
__u32 addr; /* Address to write */
__u8 *buf;

dev_dbg(&dev->dev, "load_firmware\n");
buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL);
if (!buf) {
err( "%s - error loading firmware: error = %d", __func__, -ENOMEM);
err = -ENOMEM;
if (!buf)
goto wraperr;
}

err = request_ihex_firmware(&loader_fw, "emi62/loader.fw", &dev->dev);
if (err)
Expand All @@ -112,16 +108,13 @@ static int emi62_load_firmware (struct usb_device *dev)
err = request_ihex_firmware(&firmware_fw, FIRMWARE_FW, &dev->dev);
if (err) {
nofw:
err( "%s - request_firmware() failed", __func__);
goto wraperr;
}

/* Assert reset (stop the CPU in the EMI) */
err = emi62_set_reset(dev,1);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}

rec = (const struct ihex_binrec *)loader_fw->data;

Expand All @@ -130,19 +123,15 @@ static int emi62_load_firmware (struct usb_device *dev)
err = emi62_writememory(dev, be32_to_cpu(rec->addr),
rec->data, be16_to_cpu(rec->len),
ANCHOR_LOAD_INTERNAL);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
rec = ihex_next_binrec(rec);
}

/* De-assert reset (let the CPU run) */
err = emi62_set_reset(dev,0);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
msleep(250); /* let device settle */

/* 2. We upload the FPGA firmware into the EMI
Expand All @@ -160,37 +149,29 @@ static int emi62_load_firmware (struct usb_device *dev)
rec = ihex_next_binrec(rec);
}
err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
} while (rec);

/* Assert reset (stop the CPU in the EMI) */
err = emi62_set_reset(dev,1);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}

/* 3. We need to put the loader for the firmware into the EZ-USB (again...) */
for (rec = (const struct ihex_binrec *)loader_fw->data;
rec; rec = ihex_next_binrec(rec)) {
err = emi62_writememory(dev, be32_to_cpu(rec->addr),
rec->data, be16_to_cpu(rec->len),
ANCHOR_LOAD_INTERNAL);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
}

/* De-assert reset (let the CPU run) */
err = emi62_set_reset(dev,0);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
msleep(250); /* let device settle */

/* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */
Expand All @@ -201,39 +182,31 @@ static int emi62_load_firmware (struct usb_device *dev)
err = emi62_writememory(dev, be32_to_cpu(rec->addr),
rec->data, be16_to_cpu(rec->len),
ANCHOR_LOAD_EXTERNAL);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
}
}

/* Assert reset (stop the CPU in the EMI) */
err = emi62_set_reset(dev,1);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}

for (rec = (const struct ihex_binrec *)firmware_fw->data;
rec; rec = ihex_next_binrec(rec)) {
if (INTERNAL_RAM(be32_to_cpu(rec->addr))) {
err = emi62_writememory(dev, be32_to_cpu(rec->addr),
rec->data, be16_to_cpu(rec->len),
ANCHOR_LOAD_EXTERNAL);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
}
}

/* De-assert reset (let the CPU run) */
err = emi62_set_reset(dev,0);
if (err < 0) {
err("%s - error loading firmware: error = %d", __func__, err);
if (err < 0)
goto wraperr;
}
msleep(250); /* let device settle */

release_firmware(loader_fw);
Expand All @@ -247,6 +220,9 @@ static int emi62_load_firmware (struct usb_device *dev)
return 1;

wraperr:
if (err < 0)
dev_err(&dev->dev,"%s - error loading firmware: error = %d\n",
__func__, err);
release_firmware(loader_fw);
release_firmware(bitstream_fw);
release_firmware(firmware_fw);
Expand Down

0 comments on commit e9a527d

Please sign in to comment.