-1

I am trying to compile cp210x USB-UART driver on Debian 7 and getting the following error (when make command):

/var/distr/sillabs/Linux_3.x.x_VCP_Driver_Source/cp210x.c:589:17: error: request for member ‘c_cflag’ in something not a structure or union

Here is a fragment of code, line 589 (starts with &tty->), cp210x.c:

static void cp210x_get_termios(struct tty_struct *tty,
        struct usb_serial_port *port)
{
        unsigned int baud;
        if (tty) {
                cp210x_get_termios_port(tty->driver_data,
                        &tty->termios.c_cflag, &baud);
                tty_encode_baud_rate(tty, baud, baud);
        } else {
                unsigned int cflag;
                cflag = 0;
                cp210x_get_termios_port(port, &cflag, &baud);
        }
}

I think something is wrong with the &tty->termios.c_cflag construction. Please help how to fix it?

Thank you!

Alexander
  • 73
  • 2
  • 8
  • 1
    possible duplicate of [What does "request for member '\*\*\*\*\*\*\*' in something not a structure or union" mean?](http://stackoverflow.com/questions/2184419/what-does-request-for-member-in-something-not-a-structure-or-union-m) – Яois Mar 17 '15 at 16:55
  • 1
    @KeillRandor: No, not at all. – Lightness Races in Orbit Mar 17 '15 at 17:38
  • @LightnessRacesinOrbit how is this not a duplicate? I was going to add a "it is a pointer"-like answer, but this is a generic C problem with an existing generic answer. Of course there is a different context for this particular question, but it is still a C-related problem after all. I am really curious about this, as my idea of duplicate may be inaccurate... – Яois Mar 17 '15 at 18:19
  • @KeillRandor: Your chosen duplicate is a generic question that has _nothing_ to do with the core of this problem (see my answer) in _any_ way whatsoever. So you tell me why it's a duplicate? – Lightness Races in Orbit Mar 17 '15 at 18:30
  • @LightnessRacesinOrbit I understand your point, as your answer is based on context-specific knowledge, but the fact is that the question title is "C++ compilation error: request for member ‘c_cflag' ..."!!! Anyway, you made your point, sir :) – Яois Mar 17 '15 at 18:42
  • 1
    how is this question related to `C++`? the code supplies is `C` and the file to be compiled is a `C` file (at least if we can go by it's extension) – umläute Mar 17 '15 at 20:29

3 Answers3

3

It means that in your definition of tty_struct, termios is a structure pointer, not a structure. You need to change the expression

&tty->termios.c_cflag

to

&tty->termios->c_cflag
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
swestrup
  • 4,079
  • 3
  • 22
  • 33
2

The definition of tty_struct changed between versions 2.x and 3.x of the Linux kernel.

The driver you're building expects it to contain:

struct ktermios termios, termios_locked;

from 3.x, but you are using the includes from 2.x:

struct ktermios *termios, *termios_locked;

You can either reconsider the kernel you're using to better meet the driver's requirements, or you can hack the driver's code yourself:

-  &tty->termios.c_cflag
+  &tty->termios->c_cflag

I would also suggest talking to the driver developer about this, if the requirements are unclear.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
0

a tty_struct contain, among other thing:

// from tty.h
struct tty_struct {
    int     magic;
    // some cut
    struct ktermios termios, termios_locked;
    // more cut
};

a ktermios in turn, is defined like:

// from termbits.h
struct ktermios {
    tcflag_t c_iflag;               /* input mode flags */
    tcflag_t c_oflag;               /* output mode flags */
    tcflag_t c_cflag;               /* control mode flags */
    tcflag_t c_lflag;               /* local mode flags */
    cc_t c_line;                    /* line discipline */
    cc_t c_cc[NCCS];                /* control characters */
    speed_t c_ispeed;               /* input speed */
    speed_t c_ospeed;               /* output speed */
};

and finally, a tcflag_t is:

// also from termbits.h
typedef unsigned int    tcflag_t;

so, in conclusion, it should work.

What could muck up that? My first guess would be a macro.
Prime suspect would be that you have a termios macro.
If not that, don't look for the error at line where its reported, it's probably a side-effect of something else.
For example, do you have old headers that the compiler might find instead of those you want?
If you are trying to compile a driver for v3 with headers from v2 it wont work.

sp2danny
  • 7,488
  • 3
  • 31
  • 53