Get pointer for existing device class (struct class) in Linux kernel module

Hi all!

I am trying to register a device in an existing device class, but I am

having trouble getting the pointer to an existing class.
I can create a class in a module, get the pointer to it and then use

it to register the device with:

*cl = class_create(THIS_MODULE, className);
dev_ret = device_create(*cl, NULL, *dev, NULL, driverName);

However I need to register another device in the same class with

another module, but I couldn't find a way to get the pointer to an

existing class. And I can not crete the class again in the other

module, because since class already exists class_create() returns NULL

and not the pointer to the class required by device_create().

I found in a function that returns a pointer to a class by its name googling (sorry system did not allowed to post url)

struct class * class_find(char * name)

However when I try to compile the function compiler says it does not exist.
I thougth this function was exported by the kernel (my module have
license GPL) but it appears it is not.
Maybe I need to include some header?

I know its a patch I suposed it was in main stream kernel already.
I tried to rewrite this function since the code is available. The code is:

+struct class * class_find(char * name)
+{
+	struct class * this_class;
+
+	if (!name)
+		return NULL;
+
+	list_for_each_entry(this_class, &class_subsys.kset.list, subsys.kset.kobj.entry) {
+		if (!(strcmp(this_class->name, name)))
+			return this_class;
+	}
+
+	return NULL;
+}

But when I try to iterate over class_subsys with:

list_for_each_entry(this_class, &class_subsys.kset.list, subsys.kset.kobj.entry)

now symbol class_subsys is not found. Again I thougth it is exported

to the kernel.

I am not sure what is missing. Some header?
Am I doing it the wrong way?
There is another function to do it?

I supose if I could traverse sysfs from start I could get a pointer to an existing class.
But I also did not find how to start traversing sysfs.
All functions I have seen requires a pointer to kobject or kset to

start traversing. But I have no poniter even to the root of sysfs or kernel objects, so I can not start traversin the tree to get a class pointer.

Can anyone point me in the right direction please?