mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Bharathi, Divya" <Divya.Bharathi@Dell.com>,
	"Limonciello, Mario" <Mario.Limonciello@dell.com>,
	Divya Bharathi <divya27392@gmail.com>,
	"dvhart@infradead.org" <dvhart@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"platform-driver-x86@vger.kernel.org" 
	<platform-driver-x86@vger.kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	"Ksr, Prasanth" <Prasanth.Ksr@dell.com>
Subject: Re: [PATCH v2] Introduce support for Systems Management Driver over WMI for Dell Systems
Date: Mon, 21 Sep 2020 11:38:11 +0200	[thread overview]
Message-ID: <a6dbd512-760a-bd01-28ab-7e82d18d03d8@redhat.com> (raw)
In-Reply-To: <CY4PR19MB1254A26A233052B71ACC5ACA853E0@CY4PR19MB1254.namprd19.prod.outlook.com>

Hi,

On 9/17/20 7:22 AM, Bharathi, Divya wrote:

<snip>

>>>>> +
>>>>> +/**
>>>>> + * exit_enum_attributes() - Clear all attribute data
>>>>> + * @kset: The kset to free
>>>>> + *
>>>>> + * Clears all data allocated for this group of attributes  **/ void
>>>>> +exit_enum_attributes(struct kset *kset) {
>>>>> +	struct kobject *pos, *next;
>>>>> +
>>>>> +	mutex_lock(&kset_mutex);
>>>>> +	list_for_each_entry_safe(pos, next, &kset->list, entry) {
>>>>> +		sysfs_remove_group(pos, &enumeration_attr_group);
>>>>> +	}
>>>>> +	mutex_unlock(&kset_mutex);
>>>>> +	mutex_lock(&enum_mutex);
>>>>> +	kfree(enumeration_data);
>>>>> +	mutex_unlock(&enum_mutex);
>>>>> +}
>>>>
>>>> Since there is now only 1 kset for the main dir, you are now calling
>>>> sysfs_remove_group 4 times (for all the different times) on each entry
>>>> in the attributes dir. I guess this may fail silently, but it still is
>>>> not good. So this needs to be fixed.
>>>>
>>>> The remarks to this file also apply to the:
>>>>
>>>> drivers/platform/x86/dell-wmi-int-attributes.c
>>>> drivers/platform/x86/dell-wmi-string-attributes.c
>>>>
>>>> files.
>>>>
> 
> Since we maintained 4 different attribute groups under 1 kset, each time
> respective attribute group will be removed. And once all groups are
> removed, kset is deleted.

sysfs_remove_group() just does a kernfs_remove_by_name() for each
attribute in the group.

Since the integer_, enumeration_ and string_ attr_group-s all
have e.g. a current_value attribute that means that current_value
will be removed 3 times and for the 2nd and 3th call
kernfs_remove_by_name() will fail with -ENOENT.

Currently neither kernfs_remove_by_name() nor sysfs_remove_group() print
an error message for this, but still it is not very clean.

Instead why not do this:

int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,
                         struct kobject *attr_name_kobj)
{
         int retval = sysfs_create_group(attr_name_kobj, &enumeration_attr_group);
         int i, next_obj;

         if (retval)
                 goto out;

         mutex_lock(&wmi_priv.mutex);
	enumeration_data[instance_id].attr_name_kobj = attr_name_kobj;
	/* ^^^^^^^^^^^^^^^^ This line is new ^^^^^^^^^^^^^^^^^^^^^^^^*/
	...


void exit_enum_attributes(void)
{
         int i;

         for (i = 0; i < enumeration_instances_count; i++) {
		if (enumeration_data[instance_id].attr_name_kobj)
                         sysfs_remove_group(enumeration_data[instance_id].attr_name_kobj, &enumeration_attr_group);
	}

         kfree(enumeration_data);
}


That makes the teardown mirror the setup much more closely and as such is
a cleaner solution IMHO.

Regards,

Hans


  reply	other threads:[~2020-09-21  9:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 14:28 Divya Bharathi
2020-09-11 18:31 ` mark gross
2020-09-14 10:11 ` Hans de Goede
2020-09-14 11:58 ` Hans de Goede
2020-09-14 17:12   ` Limonciello, Mario
2020-09-15 16:28     ` Bharathi, Divya
2020-09-17  5:22       ` Bharathi, Divya
2020-09-21  9:38         ` Hans de Goede [this message]
2020-09-21  9:18       ` Hans de Goede
2020-09-21  9:08     ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6dbd512-760a-bd01-28ab-7e82d18d03d8@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Divya.Bharathi@Dell.com \
    --cc=Mario.Limonciello@dell.com \
    --cc=Prasanth.Ksr@dell.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=divya27392@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®