Hi,
would someone mind checking my module initialisation function in case I
have missed something?
It loads without error and the appropriate message is printed out on the
console, buit it does not appear in /dev.
I also do not see a modules directory in /lib (this was the subject of
another question), but it may be related?
I'm compiling it as a built in module and it compiles without warnings.

Thanks
Dave W.

static int __init dave_init(void)
{
        int result;
        int err;
        dev_t device_number;
        struct cdev * the_device;

        /*
         * Allocate device number
         */
        if (!(result = alloc_chrdev_region (&device_number, 0, 1,
"fpga")))
                printk (KERN_INFO "CALREC: Device number %d, %d\n",
MAJOR(device_number), MINOR(device_number));
        else {
                printk (KERN_WARNING "CALREC: Failed to allocate
device\n");
                return result;
        }

        /*
         * Request memory region associated with CS2 (address
0x30000000)
         */
        if (!request_mem_region(FPGA_BASE, FPGA_SIZE, "fpga")) {
                printk (KERN_WARNING "CALREC: Can't request FPGA memory
region\n");
                result = -EBUSY;
                goto err1;
        }

        /*
         * Allocate the char device
         */
        the_device = cdev_alloc();
        if (!the_device) {
                printk (KERN_WARNING "CALREC: Can't allocate char
device\n");
                result = -ENOMEM;
                goto err2;
        }

        /*
         * Initialise the device
         */
        the_device->ops = &fops;
        the_device->owner = THIS_MODULE;

        /*
         * Register the device
         */
        if ((err = cdev_add(the_device, device_number, 1))) {
                printk (KERN_WARNING "CALREC: Can't add device - error
%d", err);
                goto err2;
        }

        /*
         * success
         */
        printk (KERN_INFO "CALREC: Hello, there!!");
        return 0;

/*
 * error handling
 */
err2:
        /*
         * free up the mem region
         */
        release_mem_region (FPGA_BASE, FPGA_SIZE);

err1:
        /*
         * free up the device number region
         */
        unregister_chrdev_region (device_number, 1);

        return result;
}
module_init(dave_init);




static void __exit dave_exit(void)
{
        printk (KERN_WARNING "Bye!\n");
}
module_exit(dave_exit);

MODULE_DESCRIPTION("Driver for Dave module"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:atmel_dave");


This electronic transmission is strictly confidential and intended solely for 
the addressee(s). If you are not the intended addressee, you must not disclose, 
copy or take any action in reliance of this email.  If you have received this 
email in error please notify the sender as soon as possible. Any views 
expressed within this email may not necessarily be the views held by Calrec 
Audio Ltd.  Calrec Audio Ltd have taken measures to ensure this email is free 
from computer viruses, however it is recommended that you also employ 
anti-virus measures on your computer systems.
Calrec Audio Ltd. Registered in England. Registration number: 02392336. WEEE 
registration number: WEE/JE0051TQ/PRO. Registered address: Nutclough Mill, 
Hebden Bridge, West Yorks, HX7 8EZ.

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to