Static functions in Linux device driver?

后端 未结 3 919
半阙折子戏
半阙折子戏 2021-02-20 13:25

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 pr

3条回答
  •  误落风尘
    2021-02-20 14:29

    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.

提交回复
热议问题