2 * Copyright (C) 2013 CERN (www.cern.ch)
5 * Released according to the GNU GPL, version 2 or any later version.
7 * This work is part of the White Rabbit project, a research effort led
8 * by CERN, the European Institute for Nuclear Research.
10 #include <linux/kernel.h>
11 #include <linux/moduleparam.h>
12 #include <linux/device.h>
13 #include <linux/fmc.h>
14 #include <linux/fmc-sdb.h>
16 static int fmc_must_dump_eeprom;
17 module_param_named(dump_eeprom, fmc_must_dump_eeprom, int, 0644);
21 /* Dumping 8k takes oh so much: avoid duplicate lines */
22 static const uint8_t *dump_line(int addr, const uint8_t *line,
27 if (!prev || memcmp(line, prev, LINELEN)) {
28 pr_info("%04x: ", addr);
29 for (i = 0; i < LINELEN; ) {
30 printk(KERN_CONT "%02x", line[i]);
32 printk(i & 3 ? " " : i & (LINELEN - 1) ? " " : "\n");
37 if (line == prev + LINELEN)
42 void fmc_dump_eeprom(const struct fmc_device *fmc)
44 const uint8_t *line, *prev;
47 if (!fmc_must_dump_eeprom)
50 pr_info("FMC: %s (%s), slot %i, device %s\n", dev_name(fmc->hwdev),
51 fmc->carrier_name, fmc->slot_id, dev_name(&fmc->dev));
52 pr_info("FMC: dumping eeprom 0x%x (%i) bytes\n", fmc->eeprom_len,
57 for (i = 0; i < fmc->eeprom_len; i += LINELEN, line += LINELEN)
58 prev = dump_line(i, line, prev);