Re: [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition
From: Jacek Anaszewski
Date: Mon Sep 16 2019 - 16:18:21 EST
On 9/16/19 8:34 PM, Dan Murphy wrote:
> Jacek
>
> On 9/15/19 11:20 AM, Jacek Anaszewski wrote:
>>
>>> +
>>> +static int led_multicolor_init_color(struct led_classdev_mc_data *data,
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct led_classdev_mc *mcled_cdev,
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int color_id, int color_index)
>>> +{
>>> +ÂÂÂ struct led_classdev *led_cdev = mcled_cdev->led_cdev;
>>> +ÂÂÂ struct led_classdev_mc_priv *mc_priv;
>>> +ÂÂÂ int ret;
>>> +
>>> +ÂÂÂ mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv),
>>> GFP_KERNEL);
>>> +ÂÂÂ if (!mc_priv)
>>> +ÂÂÂÂÂÂÂ return -ENOMEM;
>>> +
>>> +ÂÂÂ mc_priv->led_color_id = color_id;
>>> +ÂÂÂ mc_priv->mcled_cdev = mcled_cdev;
>>> +
>>> +ÂÂÂ data->led_kobj = kobject_create_and_add(led_colors[color_id],
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ data->color_kobj);
>> No change here since previous version? What prevents you from following
>> what has been done for drivers/usb/core/ledtrig-usbport.c?
>>
>> Use sysfs_create_group() for creating color dir
>> and sysfs_add_file_to_group() for adding files to it.
>
> We have nested directories here. colors is a directory and then the LED
> color is a directory.
>
> So I am not sure how to create a group under another group without the
> colors directory kobj.
>
> Wondering if you know of any examples?
Hmm, that indeed seems not to be allowed. kobject_create_and_add()
seems to be the only solution to achieve nested directories.
Nonetheless we will have to first justify the need for that to Greg.
--
Best regards,
Jacek Anaszewski