* Coding problem with sysfs
@ 2004-06-02 9:21 Christian Gmeiner
2004-06-04 21:05 ` Greg KH
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Christian Gmeiner @ 2004-06-02 9:21 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]
Hi Mailling list.
i have tried to wirte a sysfs patch for the dvb-driver. It seems very nice,
but i am _not_ able
to access and work with the devices.
Now i have run some tests:
1. Only register the adapter, the other functions are commented out
vdr root # ls -R /sys/class/dvb
/sys/class/dvb:
adapter0
/sys/class/dvb/adapter0:
frontend name
And i can access the infos:
vdr root # cat /sys/class/dvb/adapter0/frontend
STV0299/TSA5059/SL1935 based
vdr root # cat /sys/class/dvb/adapter0/name
KNC1 DVB-S
Looks nice....
2. Enabled full sysfs support
vdr root # ls -R /sys/class/dvb
/sys/class/dvb:
adapter0
/sys/class/dvb/adapter0:
demux0 dvr0 frontend frontend0 name net0
/sys/class/dvb/adapter0/demux0:
adap dev
/sys/class/dvb/adapter0/dvr0:
adap dev
/sys/class/dvb/adapter0/frontend0:
adap dev
/sys/class/dvb/adapter0/net0:
adap dev
vdr root # ls -Rl /dev/dvb
/dev/dvb:
total 0
drwxr-xr-x 2 root root 0 Jun 1 00:10 adapter0
/dev/dvb/adapter0:
total 0
crw-rw---- 1 root video 250, 7 Jun 1 00:10 adapter0
crw-rw---- 1 root video 250, 4 Jun 1 00:10 demux0
crw-rw---- 1 root video 250, 5 Jun 1 00:10 dvr0
crw-rw---- 1 root video 250, 3 Jun 1 00:10 frontend0
crw-rw---- 1 root video 250, 7 Jun 1 00:10 net0
Ok... /dev/dvb/adapter0/adapter0 shouldn't exist and i have an other problem
vdr root # ls /dev/dvb/adapter0/frontend0
/dev/dvb/adapter0/frontend0
vdr root # cat /dev/dvb/adapter0/frontend0
cat: /dev/dvb/adapter0/frontend0: No such device or address
If i am using devfs i get here:
vdr root # cat /dev/dvb/adapter0/frontend0
cat: /dev/dvb/adapter0/frontend0: invalid arguments
Maybe somebody can help me.
Atteched are the needed sysfs files.
Thanks,
Christian Gmeiner
[-- Attachment #2: dvb_sysfs.c --]
[-- Type: application/octet-stream, Size: 5159 bytes --]
/*
*
* dvb_sysfs.c -- interface to the sysfs filesystem
* Copyright (C) 2004 Christian Gmeiner <christian@visual-page.de>
* Copyright (C) 2004 Eric Donohue <epd3j@hotmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <linux/version.h>
#include "dvb_sysfs.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46)
#ifndef DVB_SYSFS_DIR
#define DVB_SYSFS_DIR "dvb" //-> /sys/class/dvb/...
#endif
static struct class dvb_class = {
.name = DVB_SYSFS_DIR
};
static ssize_t show_name(struct class_device *cd, char *buf)
{
struct dvb_adapter *adap = container_of(cd, struct dvb_adapter, class_dev);
sprintf(buf, "%s\n", adap->name);
return strlen(buf) + 1;
}
static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
static ssize_t show_frontend(struct class_device *cd, char *buf)
{
struct dvb_adapter *adap = container_of(cd, struct dvb_adapter, class_dev);
sprintf(buf, "%s\n", adap->frontend);
return strlen(buf) + 1;
}
static CLASS_DEVICE_ATTR(frontend, S_IRUGO, show_frontend, NULL);
static ssize_t show_devnum(struct class_device *cd, char *buf)
{
struct dvb_device *dvbdev = container_of(cd, struct dvb_device, class_dev);
dev_t dev = MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num, dvbdev->type, dvbdev->id));
return print_dev_t(buf, dev);
}
static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_devnum, NULL);
static ssize_t show_adap(struct class_device *cd, char *buf)
{
struct dvb_device *dvbdev = container_of(cd, struct dvb_device, class_dev);
sprintf(buf, "adapter%d\n", dvbdev->adapter->num);
return strlen(buf) + 1;
}
static CLASS_DEVICE_ATTR(adap, S_IRUGO, show_adap, NULL);
static struct class_device_attribute *dvb_adapter_attrs[] = {
&class_device_attr_name,
&class_device_attr_frontend,
NULL
};
static struct class_device_attribute *dvb_device_attrs[] = {
&class_device_attr_dev,
&class_device_attr_adap,
NULL
};
static void dvb_sysfs_register_adapter(struct dvb_adapter *adap)
{
char name[64] = "";
int i;
adap->class_dev.class = &dvb_class;
adap->class_dev.dev = NULL;
adap->class_dev.class_data = adap;
sprintf(name,"adapter%d", adap->num);
strcpy(adap->class_dev.class_id, name);
if(class_device_register(&adap->class_dev))
printk(KERN_ERR "Unable to register dvb class device\n");
for(i = 0; dvb_adapter_attrs[i]; i++)
class_device_create_file(&(adap->class_dev), dvb_adapter_attrs[i]);
}
static void dvb_sysfs_unregister_adapter(struct dvb_adapter *adap)
{
class_device_unregister(&(adap->class_dev));
}
static void dvb_sysfs_register_device(struct dvb_device *dvbdev)
{
int i;
char name[64] = "";
struct class_device *class_dev = &(dvbdev->class_dev);
sprintf(name,"%s%d", dnames[dvbdev->type], dvbdev->adapter->num);
class_dev->class = &dvb_class;
class_dev->class_data = dvbdev;
strcpy(class_dev->class_id, name);
kobject_init(&class_dev->kobj);
strcpy(class_dev->kobj.name, name);
class_dev->kobj.parent = &dvbdev->adapter->class_dev.kobj;
class_dev->kobj.kset = dvbdev->adapter->class_dev.kobj.kset;
class_dev->kobj.ktype = dvbdev->adapter->class_dev.kobj.ktype;
class_dev->kobj.dentry = dvbdev->adapter->class_dev.kobj.dentry;
kobject_register(&class_dev->kobj);
for (i = 0; dvb_device_attrs[i]; i++)
class_device_create_file(class_dev, dvb_device_attrs[i]);
}
static void dvb_sysfs_unregister_device(struct dvb_device *dvbdev)
{
kobject_unregister(&dvbdev->class_dev.kobj);
}
static int dvb_sysfs_init(void)
{
printk("DVB: Using sysfs funtions\n");
if (class_register(&dvb_class) != 0) {
printk("DVB: adapter class failed to register properly");
return -1;
}
return 0;
}
static void dvb_sysfs_exit(void)
{
class_unregister(&dvb_class);
}
struct dvb_registrar_s dvb_sysfs_registrar =
{
.register_adapter = &dvb_sysfs_register_adapter,
.unregister_adapter = &dvb_sysfs_unregister_adapter,
.register_device = &dvb_sysfs_register_device,
.unregister_device = &dvb_sysfs_unregister_device,
.dvbdev_init = &dvb_sysfs_init,
.dvbdev_exit = &dvb_sysfs_exit,
};
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) */
struct dvb_registrar_s dvb_sysfs_registrar =
{
.register_adapter = NULL,
.unregister_adapter = NULL,
.register_device = NULL,
.unregister_device = NULL,
.dvbdev_init = NULL,
.dvbdev_exit = NULL,
};
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) */
[-- Attachment #3: dvbdev.h --]
[-- Type: application/octet-stream, Size: 2542 bytes --]
/*
* dvbdev.h
*
* Copyright (C) 2000 Ralph Metzler & Marcus Metzler
* for convergence integrated media GmbH
* Copyright (C) 2004 Christian Gmeiner <christian@visual-page.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Lesser Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _DVBDEV_H_
#define _DVBDEV_H_
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/device.h>
#define DVB_MAJOR 250
#define DVB_DEVICE_VIDEO 0
#define DVB_DEVICE_AUDIO 1
#define DVB_DEVICE_SEC 2
#define DVB_DEVICE_FRONTEND 3
#define DVB_DEVICE_DEMUX 4
#define DVB_DEVICE_DVR 5
#define DVB_DEVICE_CA 6
#define DVB_DEVICE_NET 7
#define DVB_DEVICE_OSD 8
struct dvb_adapter {
int num;
struct list_head list_head;
struct list_head device_list;
const char *name;
char frontend[64];
u8 proposed_mac [6];
struct module *module;
// SysFs
struct class_device class_dev;
};
struct dvb_device {
struct list_head list_head;
struct file_operations *fops;
struct dvb_adapter *adapter;
int type;
u32 id;
/* in theory, 'users' can vanish now,
but I don't want to change too much now... */
int readers;
int writers;
int users;
/* don't really need those !? -- FIXME: use video_usercopy */
int (*kernel_ioctl)(struct inode *inode, struct file *file,
unsigned int cmd, void *arg);
void *priv;
// SysFs
struct class_device class_dev;
};
#include "dvb_registration.h"
// generic functions
extern int dvb_generic_open (struct inode *inode, struct file *file);
extern int dvb_generic_release (struct inode *inode, struct file *file);
extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
#endif /* _DVBDEV_H_ */
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Coding problem with sysfs 2004-06-02 9:21 Coding problem with sysfs Christian Gmeiner @ 2004-06-04 21:05 ` Greg KH 2004-06-05 0:30 ` Christian Gmeiner ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Greg KH @ 2004-06-04 21:05 UTC (permalink / raw) To: linux-hotplug On Wed, Jun 02, 2004 at 11:21:53AM +0200, Christian Gmeiner wrote: > /sys/class/dvb/adapter0: > demux0 dvr0 frontend frontend0 name net0 The 'dev' file needs to be here. That's the problem. What happens if you run udevtest /sys/class/dvb/adapter0 thanks, greg k-h ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding problem with sysfs 2004-06-02 9:21 Coding problem with sysfs Christian Gmeiner 2004-06-04 21:05 ` Greg KH @ 2004-06-05 0:30 ` Christian Gmeiner 2004-06-05 15:40 ` Greg KH ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Christian Gmeiner @ 2004-06-05 0:30 UTC (permalink / raw) To: linux-hotplug Hi Greg, > On Wed, Jun 02, 2004 at 11:21:53AM +0200, Christian Gmeiner wrote: > > /sys/class/dvb/adapter0: > > demux0 dvr0 frontend frontend0 name net0 > > The 'dev' file needs to be here. That's the problem. Oh i forgot something - my fault: vdr root # ls -Rl /sys/class/dvb /sys/class/dvb: total 0 drwxr-xr-x 5 root root 0 Jun 5 02:22 adapter0 /sys/class/dvb/adapter0: total 0 drwxr-xr-x 2 root root 0 Jun 5 02:22 demux0 drwxr-xr-x 2 root root 0 Jun 5 02:22 dvr0 -r--r--r-- 1 root root 4096 Jun 5 02:22 frontend -r--r--r-- 1 root root 4096 Jun 5 02:22 name drwxr-xr-x 2 root root 0 Jun 5 02:22 net0 /sys/class/dvb/adapter0/demux0: total 0 -r--r--r-- 1 root root 4096 Jun 5 02:22 adap -r--r--r-- 1 root root 4096 Jun 5 02:22 dev /sys/class/dvb/adapter0/dvr0: total 0 -r--r--r-- 1 root root 4096 Jun 5 02:22 adap -r--r--r-- 1 root root 4096 Jun 5 02:22 dev /sys/class/dvb/adapter0/net0: total 0 -r--r--r-- 1 root root 4096 Jun 5 02:22 adap -r--r--r-- 1 root root 4096 Jun 5 02:22 dev Frontend is missing, but thats, because i switched to new cvs, wicht seams to have some problems with my frontend. > > What happens if you run > udevtest /sys/class/dvb/adapter0 vdr root # udevtest /sys/class/dvb/adapter0 version 025 looking at '/class/dvb/adapter0' configured rule in '/etc/udev/rules.d//10-myrule.rules' at line 2 applied, 'adapter0' becomes 'dvb/adapter%n/%k' creating device node '/dev/dvb/adapter0/adapter0', major = '250', minor '7', mode = '020660', uid = '0', gid = '27' > This is my udev rule: # dvb devices SYSFS{adap}="adapter[0-9]*", NAME="dvb/adapter%n/%k" And this is the result in /dev: vdr root # ls -Rl /dev/dvb /dev/dvb: total 0 drwxr-xr-x 2 root root 0 Jun 5 02:22 adapter0 /dev/dvb/adapter0: total 0 crw-rw---- 1 root video 250, 7 Jun 5 02:22 adapter0 crw-rw---- 1 root video 250, 4 Jun 5 02:22 demux0 crw-rw---- 1 root video 250, 5 Jun 5 02:22 dvr0 crw-rw---- 1 root video 250, 7 Jun 5 02:22 net0 And here is the problem: vdr root # ls /dev/dvb/adapter0/demux0 /dev/dvb/adapter0/demux0 vdr root # cat /dev/dvb/adapter0/demux0 cat: /dev/dvb/adapter0/demux0: No such device or address with devfs: cat /dev/dvb/adapter0/demux0 -> invaild argument So i can not work/access the device via sysfs :( Thanks, Christian ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding problem with sysfs 2004-06-02 9:21 Coding problem with sysfs Christian Gmeiner 2004-06-04 21:05 ` Greg KH 2004-06-05 0:30 ` Christian Gmeiner @ 2004-06-05 15:40 ` Greg KH 2004-06-05 16:23 ` Christian Gmeiner 2004-06-07 23:38 ` Greg KH 4 siblings, 0 replies; 6+ messages in thread From: Greg KH @ 2004-06-05 15:40 UTC (permalink / raw) To: linux-hotplug On Sat, Jun 05, 2004 at 02:30:33AM +0200, Christian Gmeiner wrote: > Hi Greg, > > > On Wed, Jun 02, 2004 at 11:21:53AM +0200, Christian Gmeiner wrote: > > > /sys/class/dvb/adapter0: > > > demux0 dvr0 frontend frontend0 name net0 > > > > The 'dev' file needs to be here. That's the problem. > Oh i forgot something - my fault: > > vdr root # ls -Rl /sys/class/dvb > /sys/class/dvb: > total 0 > drwxr-xr-x 5 root root 0 Jun 5 02:22 adapter0 > > /sys/class/dvb/adapter0: > total 0 > drwxr-xr-x 2 root root 0 Jun 5 02:22 demux0 > drwxr-xr-x 2 root root 0 Jun 5 02:22 dvr0 > -r--r--r-- 1 root root 4096 Jun 5 02:22 frontend > -r--r--r-- 1 root root 4096 Jun 5 02:22 name > drwxr-xr-x 2 root root 0 Jun 5 02:22 net0 > > /sys/class/dvb/adapter0/demux0: > total 0 > -r--r--r-- 1 root root 4096 Jun 5 02:22 adap > -r--r--r-- 1 root root 4096 Jun 5 02:22 dev > > /sys/class/dvb/adapter0/dvr0: > total 0 > -r--r--r-- 1 root root 4096 Jun 5 02:22 adap > -r--r--r-- 1 root root 4096 Jun 5 02:22 dev > > /sys/class/dvb/adapter0/net0: > total 0 > -r--r--r-- 1 root root 4096 Jun 5 02:22 adap > -r--r--r-- 1 root root 4096 Jun 5 02:22 dev > Hm, how about using 'tree' instead, it's much easier to show the heirchey with it :) Anyway, how are you putting struct class_device structures into such a tree? We don't currently allow parents of them in the kernel. Are you using basic kobjects here? What hotplug events get generated when you create your "demux0" and others devices? The solution is for you to put everything under the /sys/class/dvb/ directory, and not go one level deeper. Care to post your code? > > What happens if you run > > udevtest /sys/class/dvb/adapter0 > > vdr root # udevtest /sys/class/dvb/adapter0 > version 025 > looking at '/class/dvb/adapter0' > configured rule in '/etc/udev/rules.d//10-myrule.rules' at line 2 applied, > 'adapter0' becomes 'dvb/adapter%n/%k' > creating device node '/dev/dvb/adapter0/adapter0', major = '250', minor > '7', mode = '020660', uid = '0', gid = '27' Ok, so that works :) > > > > This is my udev rule: > # dvb devices > SYSFS{adap}="adapter[0-9]*", NAME="dvb/adapter%n/%k" > > And this is the result in /dev: > > vdr root # ls -Rl /dev/dvb > /dev/dvb: > total 0 > drwxr-xr-x 2 root root 0 Jun 5 02:22 adapter0 > > /dev/dvb/adapter0: > total 0 > crw-rw---- 1 root video 250, 7 Jun 5 02:22 adapter0 > crw-rw---- 1 root video 250, 4 Jun 5 02:22 demux0 > crw-rw---- 1 root video 250, 5 Jun 5 02:22 dvr0 > crw-rw---- 1 root video 250, 7 Jun 5 02:22 net0 > > > And here is the problem: > vdr root # ls /dev/dvb/adapter0/demux0 > /dev/dvb/adapter0/demux0 > vdr root # cat /dev/dvb/adapter0/demux0 > cat: /dev/dvb/adapter0/demux0: No such device or address Ok, that's your kernel driver problem, not a udev issue :) Are you sure 250:4 is the proper major:minor assigned to your kernel object? Again, code would help here. Good luck, greg k-h ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding problem with sysfs 2004-06-02 9:21 Coding problem with sysfs Christian Gmeiner ` (2 preceding siblings ...) 2004-06-05 15:40 ` Greg KH @ 2004-06-05 16:23 ` Christian Gmeiner 2004-06-07 23:38 ` Greg KH 4 siblings, 0 replies; 6+ messages in thread From: Christian Gmeiner @ 2004-06-05 16:23 UTC (permalink / raw) To: linux-hotplug [-- Attachment #1: Type: text/plain, Size: 3829 bytes --] Hi Greg, > On Sat, Jun 05, 2004 at 02:30:33AM +0200, Christian Gmeiner wrote: > > Hi Greg, > > > > > On Wed, Jun 02, 2004 at 11:21:53AM +0200, Christian Gmeiner wrote: > > > > /sys/class/dvb/adapter0: > > > > demux0 dvr0 frontend frontend0 name net0 > > > > > > The 'dev' file needs to be here. That's the problem. > > Oh i forgot something - my fault: > > > > vdr root # ls -Rl /sys/class/dvb > > /sys/class/dvb: > > total 0 > > drwxr-xr-x 5 root root 0 Jun 5 02:22 adapter0 > > > > /sys/class/dvb/adapter0: > > total 0 > > drwxr-xr-x 2 root root 0 Jun 5 02:22 demux0 > > drwxr-xr-x 2 root root 0 Jun 5 02:22 dvr0 > > -r--r--r-- 1 root root 4096 Jun 5 02:22 frontend > > -r--r--r-- 1 root root 4096 Jun 5 02:22 name > > drwxr-xr-x 2 root root 0 Jun 5 02:22 net0 > > > > /sys/class/dvb/adapter0/demux0: > > total 0 > > -r--r--r-- 1 root root 4096 Jun 5 02:22 adap > > -r--r--r-- 1 root root 4096 Jun 5 02:22 dev > > > > /sys/class/dvb/adapter0/dvr0: > > total 0 > > -r--r--r-- 1 root root 4096 Jun 5 02:22 adap > > -r--r--r-- 1 root root 4096 Jun 5 02:22 dev > > > > /sys/class/dvb/adapter0/net0: > > total 0 > > -r--r--r-- 1 root root 4096 Jun 5 02:22 adap > > -r--r--r-- 1 root root 4096 Jun 5 02:22 dev > > > > Hm, how about using 'tree' instead, it's much easier to show the > heirchey with it :) Sure, but i also want to show as much as possible infos (owner, group,..). > > Anyway, how are you putting struct class_device structures into such a > tree? We don't currently allow parents of them in the kernel. Are you > using basic kobjects here? Yep i am using kobjects to this. I need this structure, because there can be more than one adapter. At the moment i able to get some infos like: vdr root # cat /sys/class/dvb/adapter0/name KNC1 DVB-S vdr root # cat /sys/class/dvb/adapter0/frontend STV0299/TSA5059/SL1935 based > > What hotplug events get generated when you create your "demux0" and > others devices? How can i check the hotplug events? I have here an PCI-DVB card. > The solution is for you to put everything under the /sys/class/dvb/ > directory, and not go one level deeper. > > Care to post your code? I have postes some the whole source in my first mail for this topic, but i will send it again. > > > > What happens if you run > > > udevtest /sys/class/dvb/adapter0 > > > > vdr root # udevtest /sys/class/dvb/adapter0 > > version 025 > > looking at '/class/dvb/adapter0' > > configured rule in '/etc/udev/rules.d//10-myrule.rules' at line 2 applied, > > 'adapter0' becomes 'dvb/adapter%n/%k' > > creating device node '/dev/dvb/adapter0/adapter0', major = '250', minor = > > '7', mode = '020660', uid = '0', gid = '27' > > Ok, so that works :) > > > > > > > > This is my udev rule: > > # dvb devices > > SYSFS{adap}="adapter[0-9]*", NAME="dvb/adapter%n/%k" > > > > And this is the result in /dev: > > > > vdr root # ls -Rl /dev/dvb > > /dev/dvb: > > total 0 > > drwxr-xr-x 2 root root 0 Jun 5 02:22 adapter0 > > > > /dev/dvb/adapter0: > > total 0 > > crw-rw---- 1 root video 250, 7 Jun 5 02:22 adapter0 > > crw-rw---- 1 root video 250, 4 Jun 5 02:22 demux0 > > crw-rw---- 1 root video 250, 5 Jun 5 02:22 dvr0 > > crw-rw---- 1 root video 250, 7 Jun 5 02:22 net0 > > > > > > And here is the problem: > > vdr root # ls /dev/dvb/adapter0/demux0 > > /dev/dvb/adapter0/demux0 > > vdr root # cat /dev/dvb/adapter0/demux0 > > cat: /dev/dvb/adapter0/demux0: No such device or address > > Ok, that's your kernel driver problem, not a udev issue :) Sure? I have taken the devfs code, wrote an abstract interface for it and added sysfs support, based on the devfs code. > > Are you sure 250:4 is the proper major:minor assigned to your kernel > object? I hope, i will ask the dvb maillinglist. > > Again, code would help here. Is attached! Thanks, Christian [-- Attachment #2: dvbdev.h --] [-- Type: application/octet-stream, Size: 2542 bytes --] /* * dvbdev.h * * Copyright (C) 2000 Ralph Metzler & Marcus Metzler * for convergence integrated media GmbH * Copyright (C) 2004 Christian Gmeiner <christian@visual-page.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Lesser Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef _DVBDEV_H_ #define _DVBDEV_H_ #include <linux/types.h> #include <linux/fs.h> #include <linux/poll.h> #include <linux/device.h> #define DVB_MAJOR 250 #define DVB_DEVICE_VIDEO 0 #define DVB_DEVICE_AUDIO 1 #define DVB_DEVICE_SEC 2 #define DVB_DEVICE_FRONTEND 3 #define DVB_DEVICE_DEMUX 4 #define DVB_DEVICE_DVR 5 #define DVB_DEVICE_CA 6 #define DVB_DEVICE_NET 7 #define DVB_DEVICE_OSD 8 struct dvb_adapter { int num; struct list_head list_head; struct list_head device_list; const char *name; char frontend[64]; u8 proposed_mac [6]; struct module *module; // SysFs struct class_device class_dev; }; struct dvb_device { struct list_head list_head; struct file_operations *fops; struct dvb_adapter *adapter; int type; u32 id; /* in theory, 'users' can vanish now, but I don't want to change too much now... */ int readers; int writers; int users; /* don't really need those !? -- FIXME: use video_usercopy */ int (*kernel_ioctl)(struct inode *inode, struct file *file, unsigned int cmd, void *arg); void *priv; // SysFs struct class_device class_dev; }; #include "dvb_registration.h" // generic functions extern int dvb_generic_open (struct inode *inode, struct file *file); extern int dvb_generic_release (struct inode *inode, struct file *file); extern int dvb_generic_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); #endif /* _DVBDEV_H_ */ [-- Attachment #3: dvb_sysfs.c --] [-- Type: application/octet-stream, Size: 5159 bytes --] /* * * dvb_sysfs.c -- interface to the sysfs filesystem * Copyright (C) 2004 Christian Gmeiner <christian@visual-page.de> * Copyright (C) 2004 Eric Donohue <epd3j@hotmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <linux/version.h> #include "dvb_sysfs.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) #ifndef DVB_SYSFS_DIR #define DVB_SYSFS_DIR "dvb" //-> /sys/class/dvb/... #endif static struct class dvb_class = { .name = DVB_SYSFS_DIR }; static ssize_t show_name(struct class_device *cd, char *buf) { struct dvb_adapter *adap = container_of(cd, struct dvb_adapter, class_dev); sprintf(buf, "%s\n", adap->name); return strlen(buf) + 1; } static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL); static ssize_t show_frontend(struct class_device *cd, char *buf) { struct dvb_adapter *adap = container_of(cd, struct dvb_adapter, class_dev); sprintf(buf, "%s\n", adap->frontend); return strlen(buf) + 1; } static CLASS_DEVICE_ATTR(frontend, S_IRUGO, show_frontend, NULL); static ssize_t show_devnum(struct class_device *cd, char *buf) { struct dvb_device *dvbdev = container_of(cd, struct dvb_device, class_dev); dev_t dev = MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num, dvbdev->type, dvbdev->id)); return print_dev_t(buf, dev); } static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_devnum, NULL); static ssize_t show_adap(struct class_device *cd, char *buf) { struct dvb_device *dvbdev = container_of(cd, struct dvb_device, class_dev); sprintf(buf, "adapter%d\n", dvbdev->adapter->num); return strlen(buf) + 1; } static CLASS_DEVICE_ATTR(adap, S_IRUGO, show_adap, NULL); static struct class_device_attribute *dvb_adapter_attrs[] = { &class_device_attr_name, &class_device_attr_frontend, NULL }; static struct class_device_attribute *dvb_device_attrs[] = { &class_device_attr_dev, &class_device_attr_adap, NULL }; static void dvb_sysfs_register_adapter(struct dvb_adapter *adap) { char name[64] = ""; int i; adap->class_dev.class = &dvb_class; adap->class_dev.dev = NULL; adap->class_dev.class_data = adap; sprintf(name,"adapter%d", adap->num); strcpy(adap->class_dev.class_id, name); if(class_device_register(&adap->class_dev)) printk(KERN_ERR "Unable to register dvb class device\n"); for(i = 0; dvb_adapter_attrs[i]; i++) class_device_create_file(&(adap->class_dev), dvb_adapter_attrs[i]); } static void dvb_sysfs_unregister_adapter(struct dvb_adapter *adap) { class_device_unregister(&(adap->class_dev)); } static void dvb_sysfs_register_device(struct dvb_device *dvbdev) { int i; char name[64] = ""; struct class_device *class_dev = &(dvbdev->class_dev); sprintf(name,"%s%d", dnames[dvbdev->type], dvbdev->adapter->num); class_dev->class = &dvb_class; class_dev->class_data = dvbdev; strcpy(class_dev->class_id, name); kobject_init(&class_dev->kobj); strcpy(class_dev->kobj.name, name); class_dev->kobj.parent = &dvbdev->adapter->class_dev.kobj; class_dev->kobj.kset = dvbdev->adapter->class_dev.kobj.kset; class_dev->kobj.ktype = dvbdev->adapter->class_dev.kobj.ktype; class_dev->kobj.dentry = dvbdev->adapter->class_dev.kobj.dentry; kobject_register(&class_dev->kobj); for (i = 0; dvb_device_attrs[i]; i++) class_device_create_file(class_dev, dvb_device_attrs[i]); } static void dvb_sysfs_unregister_device(struct dvb_device *dvbdev) { kobject_unregister(&dvbdev->class_dev.kobj); } static int dvb_sysfs_init(void) { printk("DVB: Using sysfs funtions\n"); if (class_register(&dvb_class) != 0) { printk("DVB: adapter class failed to register properly"); return -1; } return 0; } static void dvb_sysfs_exit(void) { class_unregister(&dvb_class); } struct dvb_registrar_s dvb_sysfs_registrar = { .register_adapter = &dvb_sysfs_register_adapter, .unregister_adapter = &dvb_sysfs_unregister_adapter, .register_device = &dvb_sysfs_register_device, .unregister_device = &dvb_sysfs_unregister_device, .dvbdev_init = &dvb_sysfs_init, .dvbdev_exit = &dvb_sysfs_exit, }; #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) */ struct dvb_registrar_s dvb_sysfs_registrar = { .register_adapter = NULL, .unregister_adapter = NULL, .register_device = NULL, .unregister_device = NULL, .dvbdev_init = NULL, .dvbdev_exit = NULL, }; #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Coding problem with sysfs 2004-06-02 9:21 Coding problem with sysfs Christian Gmeiner ` (3 preceding siblings ...) 2004-06-05 16:23 ` Christian Gmeiner @ 2004-06-07 23:38 ` Greg KH 4 siblings, 0 replies; 6+ messages in thread From: Greg KH @ 2004-06-07 23:38 UTC (permalink / raw) To: linux-hotplug On Sat, Jun 05, 2004 at 06:23:25PM +0200, Christian Gmeiner wrote: > > > > Anyway, how are you putting struct class_device structures into such a > > tree? We don't currently allow parents of them in the kernel. Are you > > using basic kobjects here? > Yep i am using kobjects to this. I need this structure, because there can be > more than one adapter. > At the moment i able to get some infos like: > vdr root # cat /sys/class/dvb/adapter0/name > KNC1 DVB-S > vdr root # cat /sys/class/dvb/adapter0/frontend > STV0299/TSA5059/SL1935 based That's fine. It's the subdirectories underneath the /sys/class/dvb/adapter0/ directory that will not work. You are attaching class_device structures by messing with the kobject parent pointer. Sorry, but we don't support that just yet in the driver model. Stick with a 1 level deep directory for device that have a "dev" file, or send in patches to the driver core :) > > What hotplug events get generated when you create your "demux0" and > > others devices? > How can i check the hotplug events? I have here an PCI-DVB card. Enable DEBUG for the lib/kobject.c file. That will spit out the hotplug events to the syslog debug file. Make sure when your device is added (modprobed or whatever) the hotplug event is getting generated. If so, udev should pick it up if it is installed properly. Good luck. greg k-h ------------------------------------------------------- This SF.Net email is sponsored by: GNOME Foundation Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. GNOME Users and Developers European Conference, 28-30th June in Norway http://2004/guadec.org _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-06-07 23:38 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-06-02 9:21 Coding problem with sysfs Christian Gmeiner 2004-06-04 21:05 ` Greg KH 2004-06-05 0:30 ` Christian Gmeiner 2004-06-05 15:40 ` Greg KH 2004-06-05 16:23 ` Christian Gmeiner 2004-06-07 23:38 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).