Code: Select all
spi->func.read(spi, 0, &data, 1)
Code: Select all
struct oga_spi_reg {
unsigned int *ce_;
unsigned int *si;
unsigned int *sck;
unsigned int *sio;
unsigned int *sel;
};
struct oga_spi_func {
void (*read)(struct oga_spi *,
unsigned int,
unsigned char *,
unsigned int);
void (*chip_erase)(struct oga_spi *);
void (*write)(struct oga_spi *,
unsigned int,
unsigned char *,
unsigned int);
};
struct oga_spi {
enum oga_spi_devices device;
unsigned char man_id;
unsigned char dev_id;
struct oga_spi_func func;
struct oga_spi_reg reg;
};
So, here is the problem. The above structure definitions are not conforming C code and the compiler lets you know.
In file included from oga_w25x_spi.c:2:
oga_spi.h:21: warning: ‘struct oga_spi’ declared inside parameter list
oga_spi.h:21: warning: its scope is only this definition or declaration, which is probably not what you want
oga_spi.h:22: warning: ‘struct oga_spi’ declared inside parameter list
oga_spi.h:26: warning: ‘struct oga_spi’ declared inside parameter list
In file included from oga_spi.c:2:
oga_spi.h:21: warning: ‘struct oga_spi’ declared inside parameter list
oga_spi.h:21: warning: its scope is only this definition or declaration, which is probably not what you want
oga_spi.h:22: warning: ‘struct oga_spi’ declared inside parameter list
oga_spi.h:26: warning: ‘struct oga_spi’ declared inside parameter list
oga_spi.c: In function ‘oga_spi_map’:
oga_spi.c:93: warning: assignment from incompatible pointer type
oga_spi.c:94: warning: assignment from incompatible pointer type
oga_spi.c:95: warning: assignment from incompatible pointer type
So, I'm looking for suggestions on how to address this. The read, write, and chip_erase functions don't actually need the whole oga_spi structure. All they need is the oga_spi_reg structure, so I could change the function signature for the three functions. That would make the above read example:
Code: Select all
spi->func.read(&(spi->reg), 0, &data, 1)
I curious what people's suggestions are for this coding conundrum.
--SS