Re: [PATCH] drm: amdkfd: Replace (un)register_chrdev() by (unregister/alloc)_chrdev_region()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 07.03.25 um 20:10 schrieb Salah Triki:
> On Wed, Mar 05, 2025 at 07:18:33PM -0500, Felix Kuehling wrote:
>> On 2025-03-05 16:08, Salah Triki wrote:
>>> Replace (un)register_chrdev() by (unregister/alloc)_chrdev_region() as
>>> they are deprecated since kernel 2.6.
>> Where is that information coming from? I see __register_chrdev documented in
>> the current kernel documentation. I see no indication that it's deprecated:
>> https://docs.kernel.org/core-api/kernel-api.html#c.__register_chrdev
>>
> In the book "Linux Device Drivers" 3ed of J. Corbet and al. (2005), it
> is indicated that using register_chrdev() is the old way to register
> char drivers, the new code should not use this interface, it should
> instead use the cdev interface. 

Yeah, but that doesn't count. Only in kernel documentation is relevant.

Regards,
Christian.

>>>   alloc_chrdev_region() generates a
>>> dev_t value, so replace the kfd_char_dev_major int variable by the
>>> kfd_char_dev_id dev_t variable and drop the MKDEV() call. Initialize a
>>> cdev structure and add it to the device driver model as register_chrdev()
>>> used to do and since alloc_chrdev_region() does not do it. Drop the
>>> iminor() call since alloc_chrdev_region() allocates only one minor number.
>>> On error and in the module exit function, remove the cdev structure from
>>> the device driver model as unregister_chrdev() used to do.
>> Sounds complicated. Your patch seems to open-code a bunch of details that
>> are neatly hidden inside register_chrdev. Why would I want all that detail
>> in my driver? I don't see an obvious advantage.
>>
> register_chrdev() registers 256 minor numbers, calling it will result in
> calling kmalloc_array(256, sizeof(struct probe), GFP_KERNEL) whereas
> calling alloc_chrdev_region() with count parameter equals to 1, which is
> the number of minor numbers requested, will result in calling
> kmalloc_array(1, sizeof(stuct probe), GFP_KERNEL). 
>
> Best Regards,
> Salah Triki 




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux