USB dependencies problems

Hello everyone

I have a problem in Linux USB C structures.
I have this definition in a directory
struct usb_device *dev; //taken from the link below

dev->state = 0; //for example, state is enum of 5-6 states and the state changes normally in the files belonging to this directory ONLY.

I have another function in USB directory 2
struct usb_gadget *gadget; //defined in the link below

Here I want to use the enumeration "state" inside *dev pointer to structure
if (dev->state == some state)
then gadget->name =something;

The problem is:
dev is not defined in this whole directory /dir2/anyfile has nothing related to usb_dev structure
but the code of dev is running if I run this area
So I cant track *dev while it is still live.

Of course I tried including files, but this ends up to 400 dependency problems of ifdef ifndef of heavenly feeling!

Is there any trick to save the current *dev from the current device? in the same module?

I had this trick in my mind:
I created
file something.h
extern struct usb_device **usb_pointer_to_save_dev;

then I went into
//I added
*usb_pointer_to_save_dev = dev;

Thenafter I tried:

in fffooo()
usb_pointer_to_save_def is not recognized here as a struct, rather the compiler thinks that it is an integer !!!!!!!

if (*usb_pointer_to_save_dev == 1) //then -COMPILES RIGHT!!!!
usb_pointer_to_dsave_dev-> //pointer dereference fails at compilation!

I failed getting that value of *dev

Any suggestion? method? or clue?
Many thanks.
Topic archived. No new replies allowed.