Hello Thomas,

No problem, thanks for your reply. I have one more question. I have noticed
that some programmers already have their own context (for example pony_spi.c,
rayer_spi.c. serprog.c, dediprog.c and others). I note that they are all
SPI. As I understood, they use the following approaches:

1. Register a callback by its own

if (register_shutdown(serprog_shutdown, NULL))
    goto init_err_cleanup_exit;

2. Fill `struct spi_master` shutdown-callback

static struct spi_master spi_master_dediprog = {
    ...
    .shutdown = dediprog_shutdown,
};

Is there any significant difference in this approaches? Or does it just
depend on code flow?


> It is awesome to have you interested in doing a project for flashrom!
> Please keep going! :)

> A reminder from me, is that we want you to send a small patch if you
> want to get accepted for a project. Have a look at the guidelines
> https://www.flashrom.org/GSoC
> You can of course ask questions if you have any. Good luck!

Thank you! I will do it as soon as I can

On Sat, 02 Apr 2022 09:19:05 +0000
Thomas Heijligen <s...@posteo.de> wrote:

> Hi Joursoir,
> 
> I'm going to reply to your questions on Monday. Sorry for the delay, I'm 
> currently not in reach of my Computer and want to look a few things up before 
> answering.
> 
> -- Thomas
> 
> On 1 April 2022 20:43:10 WEST, Joursoir <c...@joursoir.net> wrote:
> >Hello Thomas,
> >
> >I went ahead and started looking into shutdown functions. Almost of
> >them use global variables, but I already have ideas on how to rewrite
> >it. Now I start coding a prototype and want to implement struct
> >example_data. But I have run into a problem with its initialization:
> >
> >1) In theory, we can declare a static variable within each programmer's
> >file. It would be convenient, but this method has a big disadvantage.
> >We allocate private_data for every programmers but use only one.
> >
> >static struct example_data {
> >     ...
> >} private_data;
> >
> >2) It's not possible to add a variable to struct programmer_entry
> >because the structure is read only (structures in programmer.h are
> >declared as const).
> >
> >3) Use a static global variable in flashrom.c. Lesser of two evils
> >principle as they say
> >
> >static const struct programmer_entry *programmer = NULL;
> >static const char *programmer_param = NULL;
> >static void *programmer_data = NULL;
> >
> >The next issue is the initialization of programmer_data:
> >
> >a) Do it inside programmer->init(). The problem here is the duplication
> >of programmer_data init code in each function.
> >
> >b) Do it outside programmer->init(). The problem here is that we can't
> >find out the size of example_data (it can be drkaised_data,
> >it85spi_data and etc)
> >
> >programmer_data = calloc(1, sizeof(EXAMPLE_DATA));
> >if (!data) {
> >     ...
> >}
> >...
> >ret = programmer->init(&programmer_data);
> >
> >Perhaps there is some simpler solution, but I don't notice it. 
> >
_______________________________________________
flashrom mailing list -- flashrom@flashrom.org
To unsubscribe send an email to flashrom-le...@flashrom.org

Reply via email to