Angel Pons has submitted this change. ( https://review.coreboot.org/c/flashrom/+/55818 )
Change subject: buspirate_spi: Use non-zero return value from buspirate_sendrecv
......................................................................
buspirate_spi: Use non-zero return value from buspirate_sendrecv
Return values for buspirate_sendrecv come from serialport_write
and serialport_read, and those return 1s for any error. No need
to explicity assign ret = 1, because it is already 1 for error.
Follow up on commit 751afa88a7f22487069665c5d206ae490f158231
where this idea was suggested.
BUG=b:185191942
TEST=builds
Change-Id: I31fd70f607dc965d5cac1cd0116faa447dbc177a
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55818
Reviewed-by: Angel Pons <th3fanbus(a)gmail.com>
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
---
M buspirate_spi.c
1 file changed, 5 insertions(+), 15 deletions(-)
Approvals:
build bot (Jenkins): Verified
Angel Pons: Looks good to me, approved
diff --git a/buspirate_spi.c b/buspirate_spi.c
index bfd0e05..b56d422 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -629,10 +629,8 @@
/* Enter raw SPI mode */
bp_commbuf[0] = 0x01;
ret = buspirate_sendrecv(bp_commbuf, 1, 0);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if ((ret = buspirate_wait_for_string(bp_commbuf, "SPI")))
goto init_err_cleanup_exit;
if ((ret = buspirate_sendrecv(bp_commbuf, 0, 1)))
@@ -655,10 +653,8 @@
msg_pdbg("Enabling PSUs.\n");
}
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while setting power/CS/AUX(/Pull-up resistors)!\n");
ret = 1;
@@ -668,10 +664,8 @@
/* Set SPI speed */
bp_commbuf[0] = 0x60 | spispeed;
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while setting SPI speed!\n");
ret = 1;
@@ -685,10 +679,8 @@
msg_pdbg("Pull-ups enabled, so using HiZ pin output! (Open-Drain mode)\n");
}
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while setting SPI config!\n");
ret = 1;
@@ -698,10 +690,8 @@
/* De-assert CS# */
bp_commbuf[0] = 0x03;
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
- if (ret) {
- ret = 1;
+ if (ret)
goto init_err_cleanup_exit;
- }
if (bp_commbuf[0] != 0x01) {
msg_perr("Protocol error while raising CS#!\n");
ret = 1;
--
To view, visit https://review.coreboot.org/c/flashrom/+/55818
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I31fd70f607dc965d5cac1cd0116faa447dbc177a
Gerrit-Change-Number: 55818
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged
Attention is currently required from: Nico Huber, Anastasia Klimchuk.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/55934 )
Change subject: dediprog: Init-shutdown test for dediprog
......................................................................
Patch Set 3: Code-Review+1
(3 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/55934/comment/2d78b895_95715f3a
PS3, Line 9: This patch adds mocks for libusb functions. To avoid dependency on
I expect that some of the code could be reused to test other libusb programmers. Would it make sense to have libusb mocks in a separate compilation unit?
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/55934/comment/710bfe4a_1e00f15d
PS3, Line 98: /* dediprog_cmds CMD_READ_PROG_INFO */
Hmmm, how about making a patch that moves the dediprog definitions the tests need into a header?
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/55934/comment/2454c11f_9a054ff2
PS3, Line 140: 2021
Is this magic number the current year? Or does it have another meaning?
--
To view, visit https://review.coreboot.org/c/flashrom/+/55934
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I38508dfb6d7c24d42522f22fcae0c5e410c5f7ea
Gerrit-Change-Number: 55934
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 30 Jun 2021 08:11:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Anastasia Klimchuk.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/55974 )
Change subject: tests.c: Move opening brace on new line for function body
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/55974
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ia1b00bb68ec2426161bfc183d93d2c0719a949ec
Gerrit-Change-Number: 55974
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 30 Jun 2021 08:05:28 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Thomas Heijligen, Edward O'Callaghan, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/55932 )
Change subject: [RFC] spi_master: Add shutdown function in spi_master struct
......................................................................
Patch Set 2:
(4 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/55932/comment/1744ba4e_7fb50a4d
PS1, Line 14: adding another argument to register_spi_master.
> The new version seems better! If the shutdown function can be […]
I am so happy to hear this!
Patchset:
PS1:
> > I wasn't sure which one of the structs is the right place for the shutdown function, and even more […]
thank you, this is actually very useful! (as usual!)
If master is a right place, than the whole change can be done in 3 chunks spi/par/opaque (like we did with the data). Then moving data and shutdown into registered_master can be next step? But that would be internal to the core, callers won't even notice (or shouldn't notice to be precise).
>>> Only in the same file for the "few" masters that you have been looking at
so far ;)
I had commit 4f5169df5ff2b63a40d654ab133b8a3108b6a599 in mind when I said "in the same file", looks like lots of masters, but maybe I misunderstand something?
File linux_spi.c:
https://review.coreboot.org/c/flashrom/+/55932/comment/57cd61d5_24cfa2c0
PS1, Line 243: if (register_spi_master(&spi_master_linux, spi_data))
: return 1; /* core does cleanup */
: return 0;
:
> Or just […]
Done
File programmer.h:
https://review.coreboot.org/c/flashrom/+/55932/comment/097e9372_b256c172
PS1, Line 359: shutdown
> I think we'll need shutdown functions for both eventually. Starting with […]
>>>for this to be ideally called `deinit` and logically one level up in `struct programmer_entry`
There is no data one level up, but shutdown function needs data. I started thinking about programmer_entry, but then returned back to master struct, because it has data.
Maybe deinit is a different thing to what is currently called "shutdown function"?
--
To view, visit https://review.coreboot.org/c/flashrom/+/55932
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I2dc80dceca2f8204bcd0dad1f51753d7e79f1af5
Gerrit-Change-Number: 55932
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Wed, 30 Jun 2021 06:48:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Thomas Heijligen, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Hello build bot (Jenkins), Nico Huber, Thomas Heijligen, Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/55932
to look at the new patch set (#2).
Change subject: [RFC] spi_master: Add shutdown function in spi_master struct
......................................................................
[RFC] spi_master: Add shutdown function in spi_master struct
With this, register_spi_master can take care of register_shutdown
as well, and every spi master only needs to call register_spi_master
instead of calling both register_spi_master and register_shutdown.
This is alternative approach to CB:51761 which does not require
adding another argument to register_spi_master.
Testing: when I comment out free(data) in linux_spi_shutdown, test
fails with error
../linux_spi.c:235: note: block 0x55a4db276510 allocated here
ERROR: linux_spi_init_and_shutdown_test_success leaked 1 block(s)
Means, shutdown function is invoked.
Same for dummy: comment out free(data) in shutdown. It is also caught
in test
../dummyflasher.c:949: note: block 0x55e0727a6e40 allocated here
ERROR: dummy_init_and_shutdown_test_success leaked 1 block(s)
Means, shutdown function is invoked even for drivers with "old" API
(so, transition from old to new is not breaking anything).
Change-Id: I2dc80dceca2f8204bcd0dad1f51753d7e79f1af5
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
---
M linux_spi.c
M programmer.h
M spi.c
3 files changed, 9 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/32/55932/2
--
To view, visit https://review.coreboot.org/c/flashrom/+/55932
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I2dc80dceca2f8204bcd0dad1f51753d7e79f1af5
Gerrit-Change-Number: 55932
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: Nico Huber, Angel Pons, Anastasia Klimchuk.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/55974 )
Change subject: tests.c: Move opening brace on new line for function body
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/55974
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ia1b00bb68ec2426161bfc183d93d2c0719a949ec
Gerrit-Change-Number: 55974
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 30 Jun 2021 01:48:11 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Edward O'Callaghan, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/55934 )
Change subject: dediprog: Init-shutdown test for dediprog
......................................................................
Patch Set 3:
(3 comments)
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/55934/comment/311bd164_1859cc78
PS2, Line 108: /* Manual voltage setting */
> It does more than that. Probably doesn't need a comment.
Done (comment removed)
File tests/io_mock.h:
https://review.coreboot.org/c/flashrom/+/55934/comment/eb921630_dfedd186
PS2, Line 52: */
> You could also declare it above. […]
Done, it works! but I'm not sure I understand how it works... magic? :) I thought I understand why void* worked - because any pointer can be casted to void*, and real function with some pointer was replaced with wrap function with void*.
But now there is an entirely new type, which happens to have the same symbol as the old one? and they can replace each other?
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/55934/comment/5021a62f_d6ea2d1a
PS2, Line 91: void __wrap_test_outb(unsigned char value, unsigned short port)
: {
: /* LOG_ME; */
: if (current_io && current_io->outb)
: current_io->outb(current_io->state, value, port);
: }
:
: unsigned char __wrap_test_inb(unsigned short port)
: {
: /* LOG_ME; */
: if (current_io && current_io->inb)
: return current_io->inb(current_io->state, port);
: return 0;
: }
:
: void __wrap_test_outw(unsigned short value, unsigned short port)
: {
: /* LOG_ME; */
: if (current_io && current_io->outw)
: current_io->outw(current_io->state, value, port);
: }
:
: unsigned short __wrap_test_inw(unsigned short port)
: {
: /* LOG_ME; */
: if (current_io && current_io->inw)
: return current_io->inw(current_io->state, port);
: return 0;
: }
:
: void __wrap_test_outl(unsigned int value, unsigned short port)
: {
: /* LOG_ME; */
: if (current_io && current_io->outl)
: current_io->outl(current_io->state, value, port);
: }
:
: unsigned int __wrap_test_inl(unsigned short port)
: {
> this style fix that sneaked in here is a separate patch
Done CB:55974
--
To view, visit https://review.coreboot.org/c/flashrom/+/55934
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I38508dfb6d7c24d42522f22fcae0c5e410c5f7ea
Gerrit-Change-Number: 55934
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Wed, 30 Jun 2021 00:51:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Angel Pons, Anastasia Klimchuk.
Hello build bot (Jenkins), Nico Huber, Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/55934
to look at the new patch set (#3).
Change subject: dediprog: Init-shutdown test for dediprog
......................................................................
dediprog: Init-shutdown test for dediprog
This patch adds mocks for libusb functions. To avoid dependency on
libusb.h, libusb symbols for context and device handle are redefined.
Real libusb functions are never called in tests anyway, cmocka wraps
work with this without complaints.
BUG=b:181803212
TEST=builds and ninja test
Change-Id: I38508dfb6d7c24d42522f22fcae0c5e410c5f7ea
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
---
M tests/init_shutdown.c
M tests/io_mock.h
M tests/meson.build
M tests/tests.c
M tests/tests.h
5 files changed, 107 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/34/55934/3
--
To view, visit https://review.coreboot.org/c/flashrom/+/55934
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I38508dfb6d7c24d42522f22fcae0c5e410c5f7ea
Gerrit-Change-Number: 55934
Gerrit-PatchSet: 3
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset