[PATCH] USB: gadget: Add ID numbers to configfs-gadget driver names

Chanh Nguyen chanh at amperemail.onmicrosoft.com
Mon Dec 19 21:12:29 AEDT 2022



On 14/12/2022 22:24, Alan Stern wrote:
> [EXTERNAL EMAIL NOTICE: This email originated from an external sender. Please be mindful of safe email handling and proprietary information protection practices.]
> 
> 
> On Wed, Dec 14, 2022 at 11:15:48AM +0700, Chanh Nguyen wrote:
> 
>> Thanks CJ for the review!
>>
>> I've made some changes as below (in gadgets_make() to remove unnecessary
>> variables) and now trying to test it as much as possible. Will re-post it as
>> v2 if looks good soon.
>>
>> static inline struct gadget_info *to_gadget_info(struct config_item *item)
>> @@ -1623,13 +1629,25 @@ static struct config_group *gadgets_make(
>>
>>       gi->composite.gadget_driver = configfs_driver_template;
>>
>> +    gi->driver_id_number = ida_alloc(&driver_id_numbers, GFP_KERNEL);
>> +    if (gi->driver_id_number < 0)
>> +        goto err;
>> +
>> +    gi->composite.gadget_driver.driver.name =
>> +                          kasprintf(GFP_KERNEL, "configfs-gadget.%d",
>> +                                    gi->driver_id_number);
>> +    if (!gi->composite.gadget_driver.driver.name)
>> +        goto out_free_driver_id_number;
>> +
>>       gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL);
>>       gi->composite.name = gi->composite.gadget_driver.function;
>>
>>       if (!gi->composite.gadget_driver.function)
>> -        goto err;
>> +        goto out_free_driver_id_number;
> 
> This should goto out_free_driver_name.
> 

Thanks Alan! I'll update that.

> 
>>
>>       return &gi->group;
>> +
>> +out_free_driver_id_number:
>> +    ida_free(&driver_id_numbers, gi->driver_id_number);
>>   err:
>>       kfree(gi);
>>       return ERR_PTR(-ENOMEM);


More information about the openbmc mailing list