diff mbox

[BUGFIX,5/9] ACPI, DOCK: kill redundant spin lock in dock device object

Message ID 1371141152-9468-6-git-send-email-jiang.liu@huawei.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Jiang Liu June 13, 2013, 4:32 p.m. UTC
All dock device related data structures are created during driver
initialization, so kill the redundant spin lock in dock device object.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Shaohua Li <shaohua.li@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-acpi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/acpi/dock.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

Rafael Wysocki June 13, 2013, 6:28 p.m. UTC | #1
On Friday, June 14, 2013 12:32:28 AM Jiang Liu wrote:
> All dock device related data structures are created during driver
> initialization, so kill the redundant spin lock in dock device object.

As a cleanup, it definitely makes sense, but does it fix anything?

Rafael


> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Cc: Shaohua Li <shaohua.li@intel.com>
> Cc: Len Brown <lenb@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/acpi/dock.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
> index 8e578aa..cd2d5df 100644
> --- a/drivers/acpi/dock.c
> +++ b/drivers/acpi/dock.c
> @@ -57,7 +57,6 @@ struct dock_station {
>  	acpi_handle handle;
>  	unsigned long last_dock_time;
>  	u32 flags;
> -	spinlock_t dd_lock;
>  	struct mutex hp_lock;
>  	struct task_struct *owner;
>  	struct list_head dependent_devices;
> @@ -107,10 +106,7 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
>  	dd->handle = handle;
>  	INIT_LIST_HEAD(&dd->list);
>  	INIT_LIST_HEAD(&dd->hotplug_list);
> -
> -	spin_lock(&ds->dd_lock);
>  	list_add_tail(&dd->list, &ds->dependent_devices);
> -	spin_unlock(&ds->dd_lock);
>  
>  	return 0;
>  }
> @@ -168,14 +164,10 @@ find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
>  {
>  	struct dock_dependent_device *dd;
>  
> -	spin_lock(&ds->dd_lock);
> -	list_for_each_entry(dd, &ds->dependent_devices, list) {
> -		if (handle == dd->handle) {
> -			spin_unlock(&ds->dd_lock);
> +	list_for_each_entry(dd, &ds->dependent_devices, list)
> +		if (handle == dd->handle)
>  			return dd;
> -		}
> -	}
> -	spin_unlock(&ds->dd_lock);
> +
>  	return NULL;
>  }
>  
> @@ -964,7 +956,6 @@ static int __init dock_add(acpi_handle handle)
>  	dock_station->last_dock_time = jiffies - HZ;
>  
>  	mutex_init(&dock_station->hp_lock);
> -	spin_lock_init(&dock_station->dd_lock);
>  	INIT_LIST_HEAD(&dock_station->sibling);
>  	INIT_LIST_HEAD(&dock_station->hotplug_devices);
>  	INIT_LIST_HEAD(&dock_station->dependent_devices);
>
Jiang Liu June 14, 2013, 2:05 p.m. UTC | #2
On 06/14/2013 02:28 AM, Rafael J. Wysocki wrote:
> On Friday, June 14, 2013 12:32:28 AM Jiang Liu wrote:
>> All dock device related data structures are created during driver
>> initialization, so kill the redundant spin lock in dock device object.
> 
> As a cleanup, it definitely makes sense, but does it fix anything?
> 
> Rafael
Patch 3-9 are code cleanup only, I will resend them as separate patchset
later.

> 
> 
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>> Cc: Shaohua Li <shaohua.li@intel.com>
>> Cc: Len Brown <lenb@kernel.org>
>> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
>> Cc: linux-acpi@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>>  drivers/acpi/dock.c | 15 +++------------
>>  1 file changed, 3 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
>> index 8e578aa..cd2d5df 100644
>> --- a/drivers/acpi/dock.c
>> +++ b/drivers/acpi/dock.c
>> @@ -57,7 +57,6 @@ struct dock_station {
>>  	acpi_handle handle;
>>  	unsigned long last_dock_time;
>>  	u32 flags;
>> -	spinlock_t dd_lock;
>>  	struct mutex hp_lock;
>>  	struct task_struct *owner;
>>  	struct list_head dependent_devices;
>> @@ -107,10 +106,7 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
>>  	dd->handle = handle;
>>  	INIT_LIST_HEAD(&dd->list);
>>  	INIT_LIST_HEAD(&dd->hotplug_list);
>> -
>> -	spin_lock(&ds->dd_lock);
>>  	list_add_tail(&dd->list, &ds->dependent_devices);
>> -	spin_unlock(&ds->dd_lock);
>>  
>>  	return 0;
>>  }
>> @@ -168,14 +164,10 @@ find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
>>  {
>>  	struct dock_dependent_device *dd;
>>  
>> -	spin_lock(&ds->dd_lock);
>> -	list_for_each_entry(dd, &ds->dependent_devices, list) {
>> -		if (handle == dd->handle) {
>> -			spin_unlock(&ds->dd_lock);
>> +	list_for_each_entry(dd, &ds->dependent_devices, list)
>> +		if (handle == dd->handle)
>>  			return dd;
>> -		}
>> -	}
>> -	spin_unlock(&ds->dd_lock);
>> +
>>  	return NULL;
>>  }
>>  
>> @@ -964,7 +956,6 @@ static int __init dock_add(acpi_handle handle)
>>  	dock_station->last_dock_time = jiffies - HZ;
>>  
>>  	mutex_init(&dock_station->hp_lock);
>> -	spin_lock_init(&dock_station->dd_lock);
>>  	INIT_LIST_HEAD(&dock_station->sibling);
>>  	INIT_LIST_HEAD(&dock_station->hotplug_devices);
>>  	INIT_LIST_HEAD(&dock_station->dependent_devices);
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael Wysocki June 14, 2013, 2:16 p.m. UTC | #3
On Friday, June 14, 2013 10:05:47 PM Jiang Liu wrote:
> On 06/14/2013 02:28 AM, Rafael J. Wysocki wrote:
> > On Friday, June 14, 2013 12:32:28 AM Jiang Liu wrote:
> >> All dock device related data structures are created during driver
> >> initialization, so kill the redundant spin lock in dock device object.
> > 
> > As a cleanup, it definitely makes sense, but does it fix anything?
> > 
> > Rafael
> Patch 3-9 are code cleanup only, I will resend them as separate patchset
> later.

Cool, thanks!

Rafael


> >> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> >> Cc: Shaohua Li <shaohua.li@intel.com>
> >> Cc: Len Brown <lenb@kernel.org>
> >> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> >> Cc: linux-acpi@vger.kernel.org
> >> Cc: linux-kernel@vger.kernel.org
> >> ---
> >>  drivers/acpi/dock.c | 15 +++------------
> >>  1 file changed, 3 insertions(+), 12 deletions(-)
> >>
> >> diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
> >> index 8e578aa..cd2d5df 100644
> >> --- a/drivers/acpi/dock.c
> >> +++ b/drivers/acpi/dock.c
> >> @@ -57,7 +57,6 @@ struct dock_station {
> >>  	acpi_handle handle;
> >>  	unsigned long last_dock_time;
> >>  	u32 flags;
> >> -	spinlock_t dd_lock;
> >>  	struct mutex hp_lock;
> >>  	struct task_struct *owner;
> >>  	struct list_head dependent_devices;
> >> @@ -107,10 +106,7 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
> >>  	dd->handle = handle;
> >>  	INIT_LIST_HEAD(&dd->list);
> >>  	INIT_LIST_HEAD(&dd->hotplug_list);
> >> -
> >> -	spin_lock(&ds->dd_lock);
> >>  	list_add_tail(&dd->list, &ds->dependent_devices);
> >> -	spin_unlock(&ds->dd_lock);
> >>  
> >>  	return 0;
> >>  }
> >> @@ -168,14 +164,10 @@ find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
> >>  {
> >>  	struct dock_dependent_device *dd;
> >>  
> >> -	spin_lock(&ds->dd_lock);
> >> -	list_for_each_entry(dd, &ds->dependent_devices, list) {
> >> -		if (handle == dd->handle) {
> >> -			spin_unlock(&ds->dd_lock);
> >> +	list_for_each_entry(dd, &ds->dependent_devices, list)
> >> +		if (handle == dd->handle)
> >>  			return dd;
> >> -		}
> >> -	}
> >> -	spin_unlock(&ds->dd_lock);
> >> +
> >>  	return NULL;
> >>  }
> >>  
> >> @@ -964,7 +956,6 @@ static int __init dock_add(acpi_handle handle)
> >>  	dock_station->last_dock_time = jiffies - HZ;
> >>  
> >>  	mutex_init(&dock_station->hp_lock);
> >> -	spin_lock_init(&dock_station->dd_lock);
> >>  	INIT_LIST_HEAD(&dock_station->sibling);
> >>  	INIT_LIST_HEAD(&dock_station->hotplug_devices);
> >>  	INIT_LIST_HEAD(&dock_station->dependent_devices);
> >>
>
diff mbox

Patch

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 8e578aa..cd2d5df 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -57,7 +57,6 @@  struct dock_station {
 	acpi_handle handle;
 	unsigned long last_dock_time;
 	u32 flags;
-	spinlock_t dd_lock;
 	struct mutex hp_lock;
 	struct task_struct *owner;
 	struct list_head dependent_devices;
@@ -107,10 +106,7 @@  add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
 	dd->handle = handle;
 	INIT_LIST_HEAD(&dd->list);
 	INIT_LIST_HEAD(&dd->hotplug_list);
-
-	spin_lock(&ds->dd_lock);
 	list_add_tail(&dd->list, &ds->dependent_devices);
-	spin_unlock(&ds->dd_lock);
 
 	return 0;
 }
@@ -168,14 +164,10 @@  find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
 {
 	struct dock_dependent_device *dd;
 
-	spin_lock(&ds->dd_lock);
-	list_for_each_entry(dd, &ds->dependent_devices, list) {
-		if (handle == dd->handle) {
-			spin_unlock(&ds->dd_lock);
+	list_for_each_entry(dd, &ds->dependent_devices, list)
+		if (handle == dd->handle)
 			return dd;
-		}
-	}
-	spin_unlock(&ds->dd_lock);
+
 	return NULL;
 }
 
@@ -964,7 +956,6 @@  static int __init dock_add(acpi_handle handle)
 	dock_station->last_dock_time = jiffies - HZ;
 
 	mutex_init(&dock_station->hp_lock);
-	spin_lock_init(&dock_station->dd_lock);
 	INIT_LIST_HEAD(&dock_station->sibling);
 	INIT_LIST_HEAD(&dock_station->hotplug_devices);
 	INIT_LIST_HEAD(&dock_station->dependent_devices);