python基础教程 10-11例子如何执行

python基础教程 10-11例子如何执行,第1张

2020年最新Python零基础教程(高清视频)百度网盘    

5kid 复制这段内容后打开百度网盘手机App, *** 作更方便哦     

若资源有问题欢迎追问~    

你的两个文件里有重复的函数所以makefile不成功,上面的意思是叫你去掉其中一个c里的init_module函数,再在这个c文件里添加init_module函数的外部声明(就是加上extern 函数返回值init_module(参数列表),这个总看得懂吧。。?),我不知道你这两个函数是否相同,这样做会有什么影响,

1:通常export该函数。

2:获取结构体指针:在driver设个全局变量。

下面贴出自己写的xenon

flash

driver部分代码。

struct

xenon_flash_chip

{

struct

i2c_client

xenon_flash_client;

};

static

struct

xenon_flash_chip

xenon_chip;

//this

is

just

for

debug

int

xenon_flash_reread(void)

{

int

err

=

0;

u8

data;

struct

xenon_flash_chip

chip;

if(xenon_chip==NULL)

return

err;

chip=xenon_chip;

//read

07

err

=

xenon_flash_i2c_read(chip->xenon_flash_client,0x07,&data);

if

(err

<

0)

return

err;

CDBG("[xenon_flash]reg_control

reg=0x07

data=0x0%x\n",data);

//read

06

err

=

xenon_flash_i2c_read(chip->xenon_flash_client,0x06,&data);

if

(err

<

0)

return

err;

CDBG("[xenon_flash]reg_control

reg=0x06

data=0x0%x\n",data);

//read

04

err

=

xenon_flash_i2c_read(chip->xenon_flash_client,0x04,&data);

if

(err

<

0)

return

err;

CDBG("[xenon_flash]reg_control

reg=0x04

data=0x0%x\n",data);

return

err;

}

EXPORT_SYMBOL(xenon_flash_reread);

static

int

__devinit

xenon_flash_i2c_probe(struct

i2c_client

client,

const

struct

i2c_device_id

id)

{

int

rc

=

0;

static

const

u32

i2c_funcs

=

I2C_FUNC_SMBUS_BYTE_DATA

|

I2C_FUNC_SMBUS_WRITE_WORD_DATA;

struct

xenon_flash_chip

chip;

struct

xenon_flash_platform_data

pdata;

CDBG("xenon_flash_i2c_probe

called!\n");

/

check

/

if

(client->devplatform_data

==

NULL)

{

dev_err(&client->dev,

"xenon_flash

platform

data

is

NULL

exiting\n");

return

-ENODEV;

}

/

Copy

to

global

variable

/

pdata

=

client->devplatform_data;

/check

i2c

func/

if

(!i2c_check_functionality(client->adapter,

i2c_funcs))

return

-ENOSYS;

/

Allocate

memory

for

driver

data

/

chip

=

kzalloc(sizeof(struct

xenon_flash_chip),

GFP_KERNEL);

if

(!chip)

return

-ENOMEM;

xenon_chip

=

chip;

i2c_set_clientdata(client,chip);

chip->xenon_flash_client

=

client;

rc

=

xenon_flash_init_hw(chip,pdata);

if

(rc

<

0)

CDBG("xenon_flash_init_hw

initlised

failed!\n");

return

0;

}

在driver调试过程中,通常需要将关键函数export出来,在其他地方extern声明再调用调试。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/12188873.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存