[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTikMDvpEzrtFVue8gStudKONxuQmVx9B2w1JM1vO@mail.gmail.com>
Date: Mon, 7 Jun 2010 13:05:03 +0200
From: Kay Sievers <kay.sievers@...y.org>
To: Johannes Berg <johannes@...solutions.net>
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>,
Greg KH <greg@...ah.com>, netdev <netdev@...r.kernel.org>
Subject: Re: [RFC][PATCH] Fix another namespace issue with devices assigned to
classes
On Mon, Jun 7, 2010 at 12:14, Johannes Berg <johannes@...solutions.net> wrote:
> On Mon, 2010-06-07 at 11:53 +0200, Kay Sievers wrote:
>
>> > Can you please tell me then how to device_create() without a class? I
>> > cannot seem to create devices without a class at all, even using manual
>> > allocation (yuck) and device_register crashes the kernel.
>>
>> Right, this "convenience API" does not exist for buses. It's not doing
>> much, just allocates a "struct device" and fills in the few values and
>> calls device_register().
>>
>> Does your device create a device node? If not, device_create() should
>> not be used anyway, because the corresponding device_destroy() will
>> not do anything.
>
> No, it doesn't need a dev node. I tried this:
>
> + data->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
> + if (!data->dev) {
> err = -ENOMEM;
> goto failed_drvdata;
> }
> +
> + dev_set_name(data->dev, "hwsim%d", i);
> + data->dev->bus = &hwsim_bus;
> data->dev->driver = &mac80211_hwsim_driver;
>
> + err = device_register(data->dev);
> + if (err) {
> + printk(KERN_DEBUG
> + "mac80211_hwsim: device_register failed (%d)\n",
> + err);
> + goto failed_drvdata;
> + }
>
> (ignore the pluses, snipped from a patch) but it ran into a null ptr
> deref?
Oh, I see. It's probably something nobody ever did before. You try to
register a bus device which has no parent. Seems that's something
nobody ever expected to happen. :)
Your driver/subsystem is completely virtual, does not depend on any
hardware, right? If we create a virtual parent, like:
parent = kzalloc(sizeof(struct device), GFP_KERNEL);
dev_set_name(parent, "mac80211_hwsim");
device_register(parent);
An in your code:
data->dev->parent = parent;
That should give you a /sys/devices/mac80211_hwsim/ directory where
all the devices you create should show up.
If that works as expected, we should probably add something like:
struct device *device_virtual_parent(const char *name);
which will allow you to create such a parent device in the
/sys/device/virtual/ directory.
Let me know if the above hack with the virtual parent works, then we
can check what do add to the core.
Thanks,
Kay
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists