Hello,
On 19/07/2025 15:17, Ma Ke wrote:
Use cdev_del() instead of direct kobject_put() when cdev_add() fails. This aligns with standard kernel practice and maintains consistency within the driver's own error paths.
Sorry, to the extent it matters, I'm not acknowledging this.
This is merely a code styling issue, and as far as I know, there is no "standard kernel practice" on this matter. If such standard practice exists, the correct way is to prepare a patchset of *all* occurrences of kobject_put() used this way, and replace them all (e.g. fs/char_dev.c, uio/uio.c and tty/tty_io.c). Should xillybus_class be included in this patchset, I will of course ack it, not that it would matter much.
In my opinion, using cdev_del() is incorrect, as you can't delete something that failed to be added. Practically this causes no problem, but as a question of style, the kobject_put() call acts as the reversal of cdev_alloc(). This is formally more accurate, and this is the reason I chose to do it this way.
But more than anything, I find this patch pointless, unless someone explains why it has any use. I'm open to new insights.
Regards, Eli