aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/gs_fpgaboot/gs_fpgaboot.c')
-rw-r--r--drivers/staging/gs_fpgaboot/gs_fpgaboot.c57
1 files changed, 13 insertions, 44 deletions
diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
index 6aa9d7c30139..6da72858d28c 100644
--- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
+++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
@@ -46,27 +46,6 @@ static char *file = "xlinx_fpga_firmware.bit";
module_param(file, charp, S_IRUGO);
MODULE_PARM_DESC(file, "Xilinx FPGA firmware file.");
-#ifdef DEBUG_FPGA
-static void datadump(char *msg, void *m, int n)
-{
- int i;
- unsigned char *c;
-
- pr_info("=== %s ===\n", msg);
-
- c = m;
-
- for (i = 0; i < n; i++) {
- if ((i&0xf) == 0)
- pr_info(KERN_INFO "\n 0x%4x: ", i);
-
- pr_info("%02X ", c[i]);
- }
-
- pr_info("\n");
-}
-#endif /* DEBUG_FPGA */
-
static void read_bitstream(char *bitdata, char *buf, int *offset, int rdsize)
{
memcpy(buf, bitdata + *offset, rdsize);
@@ -157,12 +136,10 @@ static void gs_print_header(struct fpgaimage *fimage)
static void gs_read_bitstream(struct fpgaimage *fimage)
{
char *bitdata;
- int size;
int offset;
offset = 0;
bitdata = (char *)fimage->fw_entry->data;
- size = fimage->fw_entry->size;
readmagic_bitstream(bitdata, &offset);
readinfo_bitstream(bitdata, fimage->filename, &offset);
@@ -195,15 +172,15 @@ static int gs_read_image(struct fpgaimage *fimage)
return 0;
}
-static int gs_load_image(struct fpgaimage *fimage, char *file)
+static int gs_load_image(struct fpgaimage *fimage, char *fw_file)
{
int err;
- pr_info("load fpgaimage %s\n", file);
+ pr_info("load fpgaimage %s\n", fw_file);
- err = request_firmware(&fimage->fw_entry, file, &firmware_pdev->dev);
+ err = request_firmware(&fimage->fw_entry, fw_file, &firmware_pdev->dev);
if (err != 0) {
- pr_err("firmware %s is missing, cannot continue.\n", file);
+ pr_err("firmware %s is missing, cannot continue.\n", fw_file);
return err;
}
@@ -220,9 +197,9 @@ static int gs_download_image(struct fpgaimage *fimage, enum wbus bus_bytes)
size = fimage->lendata;
#ifdef DEBUG_FPGA
- datadump("bitfile sample", bitdata, 0x100);
+ print_hex_dump_bytes("bitfile sample: ", DUMP_PREFIX_OFFSET,
+ bitdata, 0x100);
#endif /* DEBUG_FPGA */
-
if (!xl_supported_prog_bus_width(bus_bytes)) {
pr_err("unsupported program bus width %d\n",
bus_bytes);
@@ -316,10 +293,8 @@ static int gs_fpgaboot(void)
struct fpgaimage *fimage;
fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
- if (fimage == NULL) {
- pr_err("No memory is available\n");
- goto err_out;
- }
+ if (!fimage)
+ return -ENOMEM;
err = gs_load_image(fimage, file);
if (err) {
@@ -361,50 +336,44 @@ err_out2:
err_out1:
kfree(fimage);
-err_out:
return -1;
}
static int __init gs_fpgaboot_init(void)
{
- int err, r;
-
- r = -1;
+ int err;
pr_info("FPGA DOWNLOAD --->\n");
pr_info("FPGA image file name: %s\n", file);
err = init_driver();
- if (err != 0) {
+ if (err) {
pr_err("FPGA DRIVER INIT FAIL!!\n");
- return r;
+ return err;
}
err = xl_init_io();
if (err) {
pr_err("GPIO INIT FAIL!!\n");
- r = -1;
goto errout;
}
err = gs_fpgaboot();
if (err) {
pr_err("FPGA DOWNLOAD FAIL!!\n");
- r = -1;
goto errout;
}
pr_info("FPGA DOWNLOAD DONE <---\n");
- r = 0;
- return r;
+ return 0;
errout:
finish_driver();
- return r;
+ return err;
}
static void __exit gs_fpgaboot_exit(void)