Alex Rivera | Logout

Static functions in Linux device driver?

Asked 2008-12-08T09:21:06.000
10

Is there a reason why most function definition in device driver in linux code is defined as static? Is there a reason for this?

I was told this is for scoping and to prevent namespace pollution, could anyone explain it in detail why static definition is used in this context?

Edit
Report

1 Answer

3

For the same reasons you use static in any code. You should only 'publish' your API calls, anything else opens you up to abuse, such as being able to call internal functions from outside the driver, something that would almost certainly be catastrophic.

It's good programming practice to only make visible to the outside world what's necessary. That's what encapsulation is all about.

answered 2008-12-08T09:30:56.447

Your Answer