linux之点亮led灯出现的无效操作数&问题

在Linux中开发LED驱动时遇到错误,源代码中`gpbcon`和`gpbdat`被误用。错误信息显示为无效操作数,原因在于对地址进行按位操作时未使用指针。解决方案是在操作`gpbcon`和`gpbdat`前加上`*`号,修正后代码编译运行成功。
摘要由CSDN通过智能技术生成

linux中点亮led灯时出现无效操作数的错误,源代码如下:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/arch/regs-gpio.h>
#include <asm/hardware.h>
#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/cdev.h>
#include <linux/slab.h>


volatile unsigned long gpbcon = NULL;
volatile unsigned long *gpbdat = NULL;


static struct class *firstdrv_class;
static struct class_device *firstdrv_class_dev;


int first_drv_open(struct inode *inode, struct file *file)
{
gpbcon &= ~((0x3<<(5*2))|(0x3<<(6*2))|(0x3<<(7*2))|(0x3<<(8*2)));
gpbcon |= ((0x1<<(5*2))|(0x1<<(6*2))|(0x1<<(7*2))|(0x1<<(8*2)));
//printk("first_drv_open\n");
return 0;
}
ssize_t first_drv_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
int val;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值