daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest May 16th, 2018 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int infousb_major =   0;
  2. int infousb_minor =   0;
  3. int infousb_nr_devs = 1;
  4.  
  5. static void infousb_setup_cdev(struct infousb_dev *dev, int index)
  6. {
  7.     int err, devno = MKDEV(infousb_major, infousb_minor + index);
  8.     cdev_init(&dev->cdev, &infousb_fops);
  9.     dev->cdev.owner = THIS_MODULE;
  10.     dev->cdev.ops = &infousb_fops;
  11.     err = cdev_add (&dev->cdev, devno, 1);
  12.     /* Fail gracefully if need be */
  13.     if (err)
  14.     info("Error %d adding info%d", err, index);
  15. }
  16.  
  17.  
  18. static int __init usb_infousb_init(void)
  19. {
  20.     int result, i;
  21.     dev_t dev = 0;
  22.  
  23. /*
  24.  * Get a range of minor numbers to work with, asking for a dynamic
  25.  * major unless directed otherwise at load time.
  26.  */
  27.  
  28.     if (infousb_major) {
  29.         dev = MKDEV(infousb_major, infousb_minor);
  30.         result = register_chrdev_region(dev, infousb_nr_devs, "infousb");
  31.     } else {
  32.         result = alloc_chrdev_region(&dev, infousb_minor, infousb_nr_devs,
  33.                 "scull");
  34.         infousb_major = MAJOR(dev);
  35.     }
  36.     if (result < 0) {
  37.         info("infousb: can't get major %d\n", infousb_major);
  38.         return result;
  39.     }
  40.  
  41.     for (i = 0; i < infousb_nr_devs; i++) {
  42.         infousb_setup_cdev(&infousb_devices[i], i);
  43.     }
  44.  
  45.     /* Fail gracefully if need be */
  46.     //if (err)
  47.         //printk(KERN_NOTICE "Error %d adding scull%d", err, index);
  48.  
  49.     info("registrou");
  50.     /* register this driver with the USB subsystem */
  51.     result = usb_register(&infousb_driver);
  52.     if (result)
  53.         err("usb_register failed. Error number %d", result);
  54.  
  55.     return result;
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top