Convert all messages in serprog.c to the new message infrastructure.
Signed-off-by: Sean Nelson audiohacked@gmail.com
On 09.01.2010 20:26, Sean Nelson wrote:
Convert all messages in serprog.c to the new message infrastructure.
Signed-off-by: Sean Nelson audiohacked@gmail.com
diff --git a/serprog.c b/serprog.c index 6544245..18ce64d 100644 --- a/serprog.c +++ b/serprog.c @@ -310,12 +304,11 @@ int serprog_init(void) unsigned char c; char *num; char *dev;
- printf_debug("%s\n", __func__);
- msg_pdbg("%s\n", __func__);
spew please
/* the parameter is either of format "/dev/device:baud" or "ip:port" */ if ((!programmer_param) || (!strlen(programmer_param))) { nodevice:
fprintf(stderr,
"Error: No device/host given for the serial programmer driver.\n"
exit(1); }msg_perr("Error: No device/host given for the serial programmer driver.\n" "Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n");
@@ -323,8 +316,7 @@ int serprog_init(void) len = num - programmer_param; if (!len) goto nodevice; if (!num) {
fprintf(stderr,
"Error: No port or baudrate specified to serial programmer driver.\n"
exit(1); }msg_perr("Error: No port or baudrate specified to serial programmer driver.\n" "Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n");
@@ -344,28 +336,28 @@ int serprog_init(void) free(dev); dev = NULL; free(num); num = NULL;
- printf_debug(MSGHEADER "connected - attempting to synchronize\n");
msg_pdbg(MSGHEADER "connected - attempting to synchronize\n");
sp_check_avail_automatic = 0;
sp_synchronize();
- printf_debug(MSGHEADER "Synchronized\n");
msg_pdbg(MSGHEADER "Synchronized\n");
if (sp_docommand(S_CMD_Q_IFACE, 0, NULL, 2, &iface)) {
fprintf(stderr, "Error: NAK to Query Interface version\n");
msg_perr("Error: NAK to Query Interface version\n");
exit(1); }
if (iface != 1) {
fprintf(stderr, "Error: Unknown interface version %d\n", iface);
exit(1); }msg_perr("Error: Unknown interface version %d\n", iface);
- printf_debug(MSGHEADER "Interface version ok.\n");
msg_pdbg(MSGHEADER "Interface version ok.\n");
if (sp_docommand(S_CMD_Q_CMDMAP, 0, NULL, 32, sp_cmdmap)) {
fprintf(stderr, "Error: query command map not supported\n");
exit(1); }msg_perr("Error: query command map not supported\n");
@@ -373,81 +365,77 @@ int serprog_init(void)
/* Check for the minimum operational set of commands */ if (sp_check_commandavail(S_CMD_R_BYTE) == 0) {
fprintf(stderr, "Error: Single byte read not supported\n");
exit(1); } /* This could be translated to single byte reads (if missing), *msg_perr("Error: Single byte read not supported\n");
if (sp_check_commandavail(S_CMD_R_NBYTES) == 0) {
- but now we dont support that. */
fprintf(stderr, "Error: Read n bytes not supported\n");
exit(1); } /* In the future one could switch to read-only mode if these *msg_perr("Error: Read n bytes not supported\n");
if (sp_check_commandavail(S_CMD_O_INIT) == 0) {
- are not available. */
fprintf(stderr,
"Error: Initialize operation buffer not supported\n");
exit(1); } if (sp_check_commandavail(S_CMD_O_WRITEB) == 0) {msg_perr("Error: Initialize operation buffer not supported\n");
fprintf(stderr,
"Error: Write to opbuf: write byte not supported\n");
exit(1); } if (sp_check_commandavail(S_CMD_O_DELAY) == 0) {msg_perr("Error: Write to opbuf: write byte not supported\n");
fprintf(stderr, "Error: Write to opbuf: delay not supported\n");
exit(1); } if (sp_check_commandavail(S_CMD_O_EXEC) == 0) {msg_perr("Error: Write to opbuf: delay not supported\n");
fprintf(stderr,
msg_perr( "Error: Execute operation buffer not supported\n");
exit(1); }
if (sp_docommand(S_CMD_Q_PGMNAME, 0, NULL, 16, pgmname)) {
fprintf(stderr, "Warning: NAK to query programmer name\n");
strcpy((char *)pgmname, "(unknown)"); } pgmname[16] = 0;msg_perr("Warning: NAK to query programmer name\n");
- printf(MSGHEADER "Programmer name "%s"\n", pgmname);
msg_pinfo(MSGHEADER "Programmer name "%s"\n", pgmname);
if (sp_docommand(S_CMD_Q_SERBUF, 0, NULL, 2, &sp_device_serbuf_size)) {
fprintf(stderr, "Warning: NAK to query serial buffer size\n");
}msg_perr("Warning: NAK to query serial buffer size\n");
- printf_debug(MSGHEADER "serial buffer size %d\n",
msg_pdbg(MSGHEADER "serial buffer size %d\n", sp_device_serbuf_size);
if (sp_docommand(S_CMD_Q_OPBUF, 0, NULL, 2, &sp_device_opbuf_size)) {
fprintf(stderr,
"Warning: NAK to query operation buffer size\n");
}msg_perr("Warning: NAK to query operation buffer size\n");
- printf_debug(MSGHEADER "operation buffer size %d\n",
msg_pdbg(MSGHEADER "operation buffer size %d\n", sp_device_opbuf_size);
if (sp_docommand(S_CMD_Q_BUSTYPE, 0, NULL, 1, &c)) {
fprintf(stderr, "Warning: NAK to query supported buses\n");
msg_perr("Warning: NAK to query supported buses\n");
c = CHIP_BUSTYPE_NONSPI; /* A reasonable default for now. */ } buses_supported = c;
if (sp_docommand(S_CMD_O_INIT, 0, NULL, 0, NULL)) {
fprintf(stderr, "Error: NAK to initialize operation buffer\n");
msg_perr("Error: NAK to initialize operation buffer\n");
exit(1); }
if (sp_docommand(S_CMD_Q_WRNMAXLEN, 0, NULL, 3, rbuf)) {
printf_debug(MSGHEADER "Write-n not supported");
sp_max_write_n = 0; } else { sp_max_write_n = ((unsigned int)(rbuf[0]) << 0); sp_max_write_n |= ((unsigned int)(rbuf[1]) << 8); sp_max_write_n |= ((unsigned int)(rbuf[2]) << 16);msg_pdbg(MSGHEADER "Write-n not supported");
printf_debug(MSGHEADER "Maximum write-n length %d\n",
sp_write_n_buf = malloc(sp_max_write_n); if (!sp_write_n_buf) {msg_pdbg(MSGHEADER "Maximum write-n length %d\n", sp_max_write_n);
fprintf(stderr,
"Error: cannot allocate memory for Write-n buffer\n");
} sp_write_n_bytes = 0;msg_perr("Error: cannot allocate memory for Write-n buffer\n"); exit(1);
@@ -458,10 +446,10 @@ int serprog_init(void) sp_max_read_n = ((unsigned int)(rbuf[0]) << 0); sp_max_read_n |= ((unsigned int)(rbuf[1]) << 8); sp_max_read_n |= ((unsigned int)(rbuf[2]) << 16);
printf_debug(MSGHEADER "Maximum read-n length %d\n",
} else {msg_pdbg(MSGHEADER "Maximum read-n length %d\n", sp_max_read_n ? sp_max_read_n : (1<<24));
printf_debug(MSGHEADER "Maximum read-n length not reported\n");
sp_max_read_n = 0; }msg_pdbg(MSGHEADER "Maximum read-n length not reported\n");
@@ -477,7 +465,7 @@ int serprog_init(void) static void sp_pass_writen(void) { unsigned char header[7];
- printf_debug(MSGHEADER "Passing write-n bytes=%d addr=0x%x\n",
- msg_pdbg(MSGHEADER "Passing write-n bytes=%d addr=0x%x\n",
Not sure if this should be dbg or spew. If it is called outside programmer init, it should be spew.
sp_write_n_bytes, sp_write_n_addr);
if (sp_streamed_transmit_bytes >= (7 + sp_write_n_bytes + sp_device_serbuf_size)) @@ -517,7 +505,7 @@ static void sp_execute_opbuf_noflush(void) if ((sp_max_write_n) && (sp_write_n_bytes)) sp_pass_writen(); sp_stream_buffer_op(S_CMD_O_EXEC, 0, 0);
- printf_debug(MSGHEADER "Executed operation buffer of %d bytes\n",
- msg_pdbg(MSGHEADER "Executed operation buffer of %d bytes\n",
Same here.
sp_opbuf_usage);
sp_opbuf_usage = 0; sp_prev_was_write = 0; @@ -532,7 +520,7 @@ static void sp_execute_opbuf(void)
int serprog_shutdown(void) {
- printf_debug("%s\n", __func__);
- msg_pdbg("%s\n", __func__);
spew please.
if ((sp_opbuf_usage) || (sp_max_write_n && sp_write_n_bytes)) sp_execute_opbuf(); close(sp_fd); @@ -547,14 +535,14 @@ static void sp_check_opbuf_usage(int bytes_to_be_added) sp_execute_opbuf(); /* If this happens in the mid of an page load the page load * * will propably fail. */
printf_debug(MSGHEADER
msg_pdbg(MSGHEADER
We may want to upgrade this to info. Hm. Will ask Urja, and for now we use your solution.
"Warning: executed operation buffer due to size reasons\n");
} }
void serprog_chip_writeb(uint8_t val, chipaddr addr) {
- printf_debug("%s\n", __func__);
- msg_pdbg("%s\n", __func__);
spew please
if (sp_max_write_n) { if ((sp_prev_was_write) && (addr == (sp_write_n_addr + sp_write_n_bytes))) { @@ -598,7 +586,7 @@ uint8_t serprog_chip_readb(const chipaddr addr) sp_flush_stream(); if (read(sp_fd, &c, 1) != 1) sp_die("readb byteread");
- printf_debug("%s addr=0x%lx returning 0x%02X\n", __func__, addr, c);
- msg_pdbg("%s addr=0x%lx returning 0x%02X\n", __func__, addr, c);
spew please
return c; }
@@ -607,7 +595,7 @@ static void sp_do_read_n(uint8_t * buf, const chipaddr addr, size_t len) { int rd_bytes = 0; unsigned char sbuf[6];
- printf_debug("%s: addr=0x%lx len=%lu\n", __func__, addr, (unsigned long)len);
- msg_pdbg("%s: addr=0x%lx len=%lu\n", __func__, addr, (unsigned long)len);
spew please
/* Stream the read-n -- as above. */ if ((sp_opbuf_usage) || (sp_max_write_n && sp_write_n_bytes)) sp_execute_opbuf_noflush(); @@ -644,7 +632,7 @@ void serprog_chip_readn(uint8_t * buf, const chipaddr addr, size_t len) void serprog_delay(int delay) { unsigned char buf[4];
- printf_debug("%s\n", __func__);
- msg_pdbg("%s\n", __func__);
spew please
if ((sp_max_write_n) && (sp_write_n_bytes)) sp_pass_writen(); sp_check_opbuf_usage(5);
Regards, Carl-Daniel
Convert all messages in serprog.c to the new message infrastructure. Rename some msg_pdbg to msg_pspew. Signed-off-by: Sean Nelson audiohacked@gmail.com
On 10.01.2010 00:43, Sean Nelson wrote:
Convert all messages in serprog.c to the new message infrastructure. Rename some msg_pdbg to msg_pspew. Signed-off-by: Sean Nelson audiohacked@gmail.com
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 1/9/2010 5:04 PM, Carl-Daniel Hailfinger wrote:
On 10.01.2010 00:43, Sean Nelson wrote:
Convert all messages in serprog.c to the new message infrastructure. Rename some msg_pdbg to msg_pspew. Signed-off-by: Sean Nelsonaudiohacked@gmail.com
Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
Thank You, Committed in r853.