please write appropriate comment………………
//this function only remove last node of the scull_dev because it has not any reverencing function for deleting previous nodes till the fist node.
//sir has taken one previous pointer but it also deletes only one node that is just before the last node but we want to delete or free every node…….how it will done……
// if we uses the recursion till the first will not deleted………….
int trim(struct scull_dev *start)
{
int i;
if(start)
{ if(start->data)
{
while(start->data->next)
start->data=start->data->next;
if(start->data->data)
{
for(i=QSET;i>=0;i–)
{
start->data->data[i]=NULL;
}
start->data->data=NULL;
}
else
printk(KERN_INFO”\nThere is No Qset”);
}
else start->data=NULL;
printk(KERN_INFO “\n NO Qset available”);
}
else
printk(KERN_INFO “\n There Is No Scull_dev”);
return 0;
}
you take a extra scull_qset pointer and initialize it with the starting position of the chain of scull_qset after this whatever node you want to delete you can access it from the starting pointer and make it NULL.