some time works both register and unregistered but some time it hangs the system.
some time works both register and unregistered but some time it hangs the system.
sir i have successfully register multiple devices with cdev init & cdevadd and unregistr using cdevdel & kfree and also with scull_setup_cdev function .
1.sir i have successfully register and unregister multiple devices ,,,,,,,,with simple using and with scull_setup function.
2.and also done open and release function.
The code during registration:-
scull_dev_ptr=kmalloc(NO_OF_DEVICES*sizeof(struct scull_dev),GFP_KERNEL);
memset(scull_dev_ptr,”,sizeof(struct scull_dev));
for(loopv=0;loopv<NO_OF_DEVICES;loopv++)
{
ldev=MKDEV(scull_major,scull_minor);
scull_minor=MINOR(ldev);
scull_dev_ptr[loopv].cdev_var.dev=ldev;
scull_dev_ptr[loopv].cdev_var.owner=THIS_MODULE;
cdev_init(&scull_dev_ptr[loopv].cdev_var,&fops);
ret_val_2=cdev_add(&scull_dev_ptr[loopv].cdev_var,ldev,1);
if(ret_val_2<0)
{
#ifdef DEBUG
printk(KERN_ERR “cdev_add failed”);
#endif
goto out;
}
scull_minor++;
#ifdef DEBUG
printk(KERN_INFO “minor=%d”,scull_minor);
#endif
}
The code during unregisteration:-
static void __exit cleanup_fun(void)
{
int loopv;
dev=MKDEV(scull_major,scull_minor);
printk(KERN_INFO “\nbegin: %s”,__func__);
for(loopv=0;loopv<NO_OF_DEVICES;LOOPV++)
cdev_del(&scull_dev_ptr[loopv].cdev_var);
kfree(scull_dev_ptr);
unregister_chrdev_region(dev,NO_OF_DEVICES);
#ifdef DEBUG
printk(KERN_INFO”bye for now”);
printk(KERN_INFO “name=%s,pid=%d”,current->comm,current->pid);
printk(KERN_INFO “end: %s\n”,__func__);
#endif
}
code works well..
-make (successful).
-it register my driver.(insmod successful).
-driver is present in (/proc/devices).
-rmmod also successful..
-driver is removed from(/proc/devices ).
But the problem is that “after rmmod & dmesg it leaves a message(10-15 lines)..
hw can these lines be removed ….
thegarbage lines are……
begin: initilization_fun
[ 4105.329806] major=247
[ 4105.329810] minor=1
[ 4105.329813] minor=2
[ 4105.329816] minor=3
[ 4105.329818] minor=4
[ 4105.329821] minor=5
[ 4105.329823] integer=11
[ 4105.329825] long integer=1111
[ 4105.329828] string=hello to the world of linux
[ 4105.329831] hello kernel
[ 4105.329833] name=insmod,4524
[ 4105.329836] end: initilization_fun
[ 4109.074416]
[ 4109.074418] begin: cleanup_fun
[ 4109.074430] ————[ cut here ]————
[ 4109.074441] WARNING: at lib/kobject.c:595 kobject_put+0×27/0x3c()
[ 4109.074445] Hardware name: System Product Name
[ 4109.074448] kobject: ‘(null)’ (ca22e574): is not initialized, yet kobject_put() is being called.
[ 4109.074452] Modules linked in: lkm(-) usb_storage fuse ebtable_nat ebtables ipt_MASQUERADE iptable_nat nf_nat bridge stp llc deflate zlib_deflate ctr camellia cast5 rmd160 crypto_null ccm serpent blowfish twofish twofish_common ecb xcbc cbc sha256_generic sha512_generic des_generic aes_i586 aes_generic ah6 ah4 esp6 esp4 xfrm4_mode_beet xfrm4_tunnel tunnel4 xfrm4_mode_tunnel xfrm4_mode_transport xfrm6_mode_transport xfrm6_mode_ro xfrm6_mode_beet xfrm6_mode_tunnel ipcomp ipcomp6 xfrm_ipcomp xfrm6_tunnel tunnel6 af_key sunrpc cpufreq_ondemand acpi_cpufreq mperf capi capifs kernelcapi ip6t_REJECT nf_conntrack_ipv6 ip6table_filter ip6_tables ipv6 vfat fat kvm_intel kvm uinput snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_hwdep snd_seq snd_seq_device i2c_i801 snd_pcm iTCO_wdt iTCO_vendor_support snd_timer snd soundcore snd_page_alloc ppdev parport_pc parport asus_atk0110 r8169 mii microcode i915 drm_kms_helper drm i2c_algo_bit i2c_core video output [last unloaded: lkm]
[ 4109.074568] Pid: 4532, comm: rmmod Tainted: G W 2.6.35.6-45.fc14.i686 #1
[ 4109.074572] Call Trace:
[ 4109.074581] [] warn_slowpath_common+0x6a/0x7f
[ 4109.074587] [] ? kobject_put+0×27/0x3c
[ 4109.074594] [] warn_slowpath_fmt+0x2b/0x2f
[ 4109.074599] [] kobject_put+0×27/0x3c
[ 4109.074606] [] cdev_del+0×22/0×25
[ 4109.074613] [] cleanup_fun+0×39/0x8f [lkm]
[ 4109.074619] [] sys_delete_module+0×181/0x1de
[ 4109.074627] [] ? audit_syscall_entry+0×116/0×138
[ 4109.074634] [] ? syscall_trace_enter+0×104/0×119
[ 4109.074641] [] syscall_call+0×7/0xb
[ 4109.074646] —[ end trace 6800ebedf54ef408 ]—
[ 4109.074649] bye for now
[ 4109.074652] name=rmmod,4532
[ 4109.074655] end: cleanup_fun
Could any body try his guts to tell me the algorithm of character driver and the meaning of each function…………….like init,alloc,add etc. My knowledge base about char driver upto registration, of module in 2.6.x kernel
how i can remove my garbage data when i read file with the chunks of four bytes each times, problem is occured at the eof , because it ignored it when we opened file as stream by using handler
The following code is meant to create a Linked List. The code is running and it shows no error. Is this the correct way of creating a linked list….????
1
2
3 #include<stdio.h>
4 #include <stdlib.h>
5 struct node
6 {
7 int info;
8 struct node *ptr;
9 };
10 struct node *start,*temp;
11
12 //*temp=*start=(struct node*)malloc(sizeof(struct node))
13
14 int main()
15 {
16 int i;
17 start=temp=(struct node*)malloc(sizeof(struct node));
18
19 for(i=0 ; i <3 ; i++)
20 {
21 temp=(struct node*)malloc(sizeof(struct node));
22 temp=temp->ptr;
23 }
24 return 0;
25 }
pls tell me the different issue associated with malloc and kmalloc ? and what is different betn them?
#include”header24.h”
int i,retvl;
module_param(i,int,S_IRUGO);
int init_function(void)
{
retvl=register_chrdev(0,”my_reg”,&fops);
if(retvl<0)
printk(KERN_ERR “error\n”);
printk(KERN_INFO “retvl=%d\n”,retvl);
printk(KERN_INFO “HELLO WORLD\n”);
printk(KERN_INFO “process name=%s \t process id=%d”,current->comm,current->pid);
printk(KERN_INFO “i=%d\n”,i);
return 0;
}
void exit_function(void)
{
unregister_chrdev(retvl,”my_reg”);
printk(KERN_INFO “BYE\n”);
}
will anyone suggest me the difference b/w-
int flag;
const int flag;
static int flag;
In Q14, I’m reading the input through scanf. // scanf(“%c”,&arr[i]); in a while loop. The problem is it is taking two characters for a single character entered. I guess it is even taking ‘Enter’ / Carriage return as a input character. Someone suggested to use scanf(“\n%c”,&arr[i]); and it worked. But I wasn’t able to understand the reason. Even fflush(stdout) was suggested. Can anyone explain me the reason precisely ? Thanks in advance.
how could the compiler compile the following statement
z >= y >= x ? 1 : 0
int main()
{
float a,
a = 2.0e20;
printf(“%f”,a);
}
Here looking at the program we expect that the output should be like 200..( 0 for 20 times).
but to our astonishment we are getting the output as 200000004008175468544.
Can anyone please tell me the reason behind such an output.?
configure: creating cache ./config.cache
checking build system type… arm-unknown-linux-gnu
checking host system type… arm-unknown-linux-gnu
checking target system type… arm-unknown-linux-gnu
checking LIBRARY_PATH variable… ok
checking GCC_EXEC_PREFIX variable… ok
checking whether to place generated files in the source directory… no
checking whether a default linker was specified… no
checking whether a default assembler was specified… no
checking for arm-linux-gcc… arm-linux-gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… configure: error: cannot run C compiled programs.
If you meant to cross compile, use `–host’.
See `config.log’ for more details.
make: *** [configure-gcc] Error 1