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:
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)
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:
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?
Last edited by jim mcnamara; 04-20-2013 at 05:08 PM..
Hello All,
I am a learner in C++. I was testing my inheritance knowledge with following piece of code.
#include <iostream>
using namespace std;
class base
{
public :
void display()
{
cout << "In base display()" << endl;
}
void display(int k)
{... (2 Replies)
I have the two class definition as follows.
class A { public: int a; };
class B : virtual public A{ };
The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Hi,
I believe the next code is wrong:
class Egg {
Egg e;
int i;
Egg(int ii=0) : i(ii) {}
};
because you would end up with an endless definition (memory allocation) of Egg objects, thus int i.
Ok, so God Eckel proposes for a singleton:
class Egg {
static Egg e;
int... (5 Replies)
I have been reading prep questions for my second unix academy exam, and there's a nuance, I'm not sure I understand it correctly.
I've been under impression from my readings of book by Evi Nemeth and from unix academy DVDs I've been watching, that kernel's modules are drivers. I think of it, as... (25 Replies)
Hello everyone,
I have a question, that are the following ways of pointer intialization same ?
ClassA *point;
point = 0;
point = new ClassA;
Thanks a load in advance!!
Regards, (10 Replies)
I'll be gratefull for any help. Thanks.
:)
This is the non class type error:
# g++ -I/usr/include/mysql -I/usr/include/mysql++ -lmysqlpp -L/usr/lib/mysql -L/usr/local/lib/mysql++ loaddsgsports.cpp -o loaddsgsports
loaddsgsports.cpp: In function âint outputToImport(const char*, const char*,... (1 Reply)
Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento)
typedef struct elemento
{
char name;
char value;
List<struct elemento> ltElementos;
... (7 Replies)
im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
I write kernel module with kernel threads using
linux/kthread.h on 2.6.* kernel
I tried to passing data between two kernel threads
with data argument of kthread_run( fun, data , NAME );
but this is not work I dont know why. I tried many possibility
and nothing works.
So I thought that... (0 Replies)
This is my code:
#!/usr/bin/perl -w
use strict;
use Class::Struct;
struct App =>
{
name => '$',
};
sub App::name
{
my $self = shift;
if( @_ )
{
$self->{'name'} = shift;
}
return $self->{'name'}; (3 Replies)