register_blkdev() and __register_chrdev_region() treat the major number as an unsigned int. So print it the same way to avoid absurd error statements such as: "... major requested (-1) is greater than the maximum (511) ..." (and also fix off-by-one bugs in the error prints). While at it, also update the comment describing register_blkdev().
Showing the changes to fs/char_dev.c (1 of 2 files). Show all
Unified · Split
| @@ -121,8 +121,8 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, · 120 unmodified lines | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | if (major >= CHRDEV_MAJOR_MAX) { | 123 | if (major >= CHRDEV_MAJOR_MAX) { |
| 124 | pr_err("CHRDEV \"%s\" major requested (%d) is greater than the maximum (%d)\n", | 124 | pr_err("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n", |
| 125 | name, major, CHRDEV_MAJOR_MAX); | 125 | name, major, CHRDEV_MAJOR_MAX-1); |
| 126 | ret = -EINVAL; | 126 | ret = -EINVAL; |
| 127 | goto out; | 127 | goto out; |
| 128 | } | 128 | } |