with regards to the first Q about Ex5.1
when do we use register_chrdev_region?
when do we use alloc_chrdev_region?
you should not use register_chrdev_region and you should use alloc_chrdev_region instead, unless you want to check manually which major number is free to use, then you can use register_chrdev_region instead alloc_chrdev_region.
As Adi concludes
register_chrdev_region should only be used if you have a specific MAJOR number you want to use.