On platform device template.

2014-08-10 Thread mind entropy
Hi,

  I am testing out the platform driver and would like to know the
template for platform device register/unregister.

  The following code causes a crash whenever the device gets unregistered.

---
#include linux/init.h
#include linux/kernel.h
#include linux/module.h
#include linux/module.h
#include linux/platform_device.h
#include linux/device.h

struct test_platform_data {
int x;
int y;
};

static struct test_platform_data test_pd = {
.x = 2,
.y = 3,
};

static struct platform_device test_platform_device = {
.name = test-plat,
.id = -1,
.resource = NULL,
.num_resources = 0,
.dev = {
.platform_data = test_pd,
}
};

static int __init platform_driver_test_init(void) {
int retval = 0;

printk(KERN_ALERT Platform driver init\n);

retval = platform_device_register(test_platform_device);

if(retval != 0) {
printk(KERN_ALERT Could not register platform device\n);
return retval;
} else {
printk(KERN_ALERT Registered platform device\n);
printk(KERN_ALERT Unregistering\n);

platform_device_unregister(test_platform_device);

}

return 0;
}

static void __exit platform_driver_test_exit(void) {
printk(KERN_ALERT Platform driver exit\n);
}

module_init(platform_driver_test_init);
module_exit(platform_driver_test_exit);

MODULE_LICENSE(GPL);
MODULE_AUTHOR(TEST);
MODULE_DESCRIPTION(Platform driver test);

---

Should the platform device be created using platform_device_alloc(..)
and added using platform_device_add(..)  like the below code?



#include linux/init.h
#include linux/kernel.h
#include linux/module.h
#include linux/module.h
#include linux/platform_device.h
#include linux/device.h

struct test_platform_data {
int x;
int y;
};

static struct test_platform_data test_pd = {
.x = 2,
.y = 3,
};


static struct platform_device *test_platform_device;

static int __init platform_driver_test_init(void) {
int retval = 0;

printk(KERN_ALERT Platform driver init\n);

test_platform_device = platform_device_alloc(test-plat,-1);

if(test_platform_device == NULL) {
printk(KERN_ALERT Could not allocate platform device\n);

return 0;
}

platform_device_add_data(test_platform_device,test_pd,sizeof(test_pd));

retval = platform_device_add(test_platform_device);

if(retval != 0) {
printk(KERN_ALERT Could not register platform device\n);
return retval;
} else {
printk(KERN_ALERT Registered platform device\n);
printk(KERN_ALERT Unregistering\n);

platform_device_unregister(test_platform_device);

}


return 0;
}

static void __exit platform_driver_test_exit(void) {
printk(KERN_ALERT Platform driver exit\n);
}

module_init(platform_driver_test_init);
module_exit(platform_driver_test_exit);

MODULE_LICENSE(GPL);
MODULE_AUTHOR(TEST);
MODULE_DESCRIPTION(Platform driver test);




Thanks,
Gautam.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


CentOS 7.0 NFS dual mount

2014-08-10 Thread Saket Sinha
Hi,

 I have a customized stackable filesystem(an extension of wrapfs or
eCryptFS) which actually mounts over lower filesystems and even Network
filesystems such as NFS and CIFS.

I mount this filesystem in init.d service and everything was working fine.
Now I have ported my filesystem on CentOS-7 and everything is working fine
except that I get two NFS mount points at startup. (Ofcourse I have added
the NFS entry in fstab.)

Since this issue was not coming on any previous versions of CentOS/RHEL
except  CentOS-7/RHEL-7.0, I researched as to was has changed in the boot
order and system startup. There is a big difference with the introduction
of systemd, which tries to parallelize the startup of services, whereas
this process has been serial with the init daemon.

Can this be related with the problem I am facing?. Any help would be
appreciated.

Regards,
Saket Sinha
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Questions about Tasklets and other Bottom Halves

2014-08-10 Thread Nick Krause
Hey Guys,
I am a few basic and perhaps stupid questions. After doing some
research, why are we using a worker thread for usb
drivers and the like versus softrqs for networking. I am assuming this
is due to the networking stack in need of more
scalability versus USB and timing demands and various things . I am
also curious, not from a theoretical as I am reading
Linux Kernel Development( if Robert is reading this, great job on this
book :) ) and learning a lot, need to brush up some of my
kernel skills as stated. Further more I am wondering when are tasklets
too slow or not scalable enough and we need
to move to softriqs, I am asking from experience and not theoretical
as i can just Google or read  my copy of LKD.
Regards Nick

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies