Linux-已注册设备的列表 [英] Linux - list of registered devices

查看:304
本文介绍了Linux-已注册设备的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Linux驱动程序,用于为Flattened-Device-Tree(FDT)中的每个兼容设备节点注册一个char设备.

I have a linux driver that registers a char device for every compatible device-node in the Flattened-Device-Tree(FDT).

在初始化时,驱动程序会分配一个主要设备号和一系列次要设备号. 当我查看/proc/devices时,将列出此主要设备号.

On initialization, the driver allocates a major device number and a range of minor device numbers. when i look at /proc/devices, this major device number is listed.

现在,当我定义2个与该驱动程序兼容的设备节点时,在FDT中,该驱动程序的platform-probe-function函数被调用了两次,并且2个char设备在相同的主设备号下注册,但在次设备号上递增设备编号.

Now, when I define 2 device-nodes, compatible with that driver, in the FDT, the driver's platform-probe-function get's called twice, and 2 char devices are registered under the same major device number, but with ascending minor device numbers.

由于我可以查找主设备号,并且我确实知道有多少个设备,并且次设备号从0开始,因此我只需键入mknod -m 666 /dev/mydevice1 c 246 0mknod -m 666 /dev/mydevice2 c 246 1即可为两个char设备创建设备节点.

Since I can lookup the major number, and I do know how many devices I have and that the minor numbers start at 0, I can just type mknod -m 666 /dev/mydevice1 c 246 0 and mknod -m 666 /dev/mydevice2 c 246 1 to create device nodes for the two char devices.

但是我想知道是否有一种方法可以查找系统已知的所有设备的主要设备号和次要设备号,因此我不必事先知道次要设备号就可以创建设备这些设备的节点?

But I am wondering if there is a way I can lookup all the devices known to the system with their major and minor device numbers, so I do not have to know the minor number beforehand, in order to be able to create device nodes for those devices?

推荐答案

使用以下命令:

ls -l /sys/dev/char/

这篇关于Linux-已注册设备的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆