Skip to contentSkip to conversation

policy on externs

DISCUSSION Justin Skists 2 participants 3 messages Jun 2, 2018

lore
Share & tools
lore
#0 lore raw

Hi,

What is the kernel policy on using "extern" to share variables between source files in a module?

I've been looking at one subsystem in staging [that shares variables quite a bit] to becoming familar with it, and seeing if I can help do some work on it in my free time.

Personally I prefer to see them eradicated (they polute the namespace), and store such variables in a context structure that is passed around. But I don't see any reference about it in the coding style, and I am not one to code-churn just because it's not my personal style! :)

Thanks,
Justin

#1 lore raw
Quoted 5 lines · Justin Skists

Hi,

What is the kernel policy on using "extern" to share variables between source files in a module?

Quoted 8 lines

I've been looking at one subsystem in staging [that shares variables quite a bit] to becoming familar with it, and seeing if I can help do some work on it in my free time.

Personally I prefer to see them eradicated (they polute the namespace), and store such variables in a context structure that is passed around. But I don't see any reference about it in the coding style, and I am not one to code-churn just because it's not my personal style! :)

context structures are almost always best, as they can be tied to the hardware device, not the module itself. So yes, if they can be eradicated, please do so.

What driver are you looking at?

thanks,

greg k-h

#2 lore raw
Quoted 10 lines · Greg KH
Quoted 9 lines · Justin Skists

Hi,

What is the kernel policy on using "extern" to share variables between source files in a module?

I've been looking at one subsystem in staging [that shares variables quite a bit] to becoming familar with it, and seeing if I can help do some work on it in my free time.

Quoted 8 lines
Quoted 4 lines

Personally I prefer to see them eradicated (they polute the namespace), and store such variables in a context structure that is passed around. But I don't see any reference about it in the coding style, and I am not one to code-churn just because it's not my personal style! :)

context structures are almost always best, as they can be tied to the hardware device, not the module itself. So yes, if they can be eradicated, please do so.

OK, Greg. I'll have another look at it, then.

Quoted 1 line

What driver are you looking at?

I have been looking at the speakup subsystem.

Thanks,
Justin.