• Linux 驱动框架---模块参数


    Linux 模块的参数

    通过在内核模块中定义模块参数从而可以在安装模块时通过insmod module_name paramname=param形式给模块传递参数。如果安装模块是传参数则将使用模块内定义的缺省值。并且最后的/sys/module/目录下会呈现出来进行读写(当读写权限为0时不会出现在目录中)。

    定义方式

    定义单个参数

    1.  定义变量(像定义普通变量的方式一样定义变量)。
    2.  使用后module_param 声明模块变量如module_param(param_name,param_type,RW Authority )。
    eg:
    static char*   param_name="xxxxxxx"
    module_param(param_name,charp,S_IRUGO)
    

    定义参数组

    1.  定义数组变量(像定义普通数组变量的方式一样定义变量)。
    2.  使用后module_param_array 声明模块变量
    eg:
    static int  param_name[cnt]="xxxxxxx"
    module_param_array(param_name,cnt,charp,S_IRUGO)
    

    参数类型

    • byte 字节参数
    • short 有符号半字参数
    • ushort 无符号半字参数
    • int 有符号整形参数
    • uint 无符号整形参数
    • long 有符号长整形参数
    • ulong 无符号长整形参数
    • charp 字符指针
    • bool bool值

    权限

    可以使用Linux定义的权限宏或运算组合,也可以使用权限位的数字如0644来表示。

    • S_IRUSR
      Permits the file's owner to read it.
    • S_IWUSR
      Permits the file's owner to write to it.
    • S_IRGRP
      Permits the file's group to read it.
    • S_IWGRP
      Permits the file's group to write to it
  • 相关阅读:
    【转】ubuntu 12.04 LTS 网络配置要点
    Sqlite3在FS_S5PC100开发板上的移植
    java中常用的字符串的截取方法
    一种很好的程序调试方法!
    win7修复MBR
    .tar.xz文件的解压
    linux环境下LED驱动编程一例
    Eclipse设置:背景与字体大小和xml文件中字体大小调整
    ARM LDR与MOV的区别
    windows下从任意目录快速进入CMD
  • 原文地址:https://www.cnblogs.com/w-smile/p/14322130.html
Copyright © 2020-2023  润新知