1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2013 CERN (www.cern.ch)
4 * Author: Alessandro Rubini <rubini@gnudd.com>
6 * This work is part of the White Rabbit project, a research effort led
7 * by CERN, the European Institute for Nuclear Research.
9 #include <linux/kernel.h>
10 #include <linux/moduleparam.h>
11 #include <linux/device.h>
12 #include <linux/fmc.h>
13 #include <linux/fmc-sdb.h>
15 static int fmc_must_dump_eeprom
;
16 module_param_named(dump_eeprom
, fmc_must_dump_eeprom
, int, 0644);
20 /* Dumping 8k takes oh so much: avoid duplicate lines */
21 static const uint8_t *dump_line(int addr
, const uint8_t *line
,
26 if (!prev
|| memcmp(line
, prev
, LINELEN
)) {
27 pr_info("%04x: ", addr
);
28 for (i
= 0; i
< LINELEN
; ) {
29 printk(KERN_CONT
"%02x", line
[i
]);
31 printk(i
& 3 ? " " : i
& (LINELEN
- 1) ? " " : "\n");
36 if (line
== prev
+ LINELEN
)
41 void fmc_dump_eeprom(const struct fmc_device
*fmc
)
43 const uint8_t *line
, *prev
;
46 if (!fmc_must_dump_eeprom
)
49 pr_info("FMC: %s (%s), slot %i, device %s\n", dev_name(fmc
->hwdev
),
50 fmc
->carrier_name
, fmc
->slot_id
, dev_name(&fmc
->dev
));
51 pr_info("FMC: dumping eeprom 0x%x (%i) bytes\n", fmc
->eeprom_len
,
56 for (i
= 0; i
< fmc
->eeprom_len
; i
+= LINELEN
, line
+= LINELEN
)
57 prev
= dump_line(i
, line
, prev
);