[ltp] Issue in ThinkPad ACPI Extras v0.21-20080629

Henrique de Moraes Holschuh linux-thinkpad@linux-thinkpad.org
Thu, 3 Jul 2008 11:47:32 -0300


--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Please try the attached patch, and tell me if it fixes the issue.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

--IS0zKkzwUGydFO0o
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="rfkill_allow-toggle-radio-errors-on-register.patch"

commit 052fa8baa08f0a2ff4f2f1f4bdee9fbd99e06063
Author: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Date:   Thu Jul 3 11:43:26 2008 -0300

    rfkill: allow toggle_radio errors when registering
    
    rfkill_add_switch() calls rfkill_toggle_radio() to set the radio of a
    recently registered rfkill class to the current global state [for that
    rfkill->type].
    
    And the rfkill_toggle_radio() call is going to error out if the radio is
    RFKILL_STATE_HARD_BLOCKED, and the global state is RFKILL_STATE_UNBLOCKED.
    That is a quite normal situation which I missed to account for.  This
    causes rfkill_register to bail out with an error.
    
    Change rfkill_add_switch() to not return errors because of a failed call to
    rfkill_toggle_radio().  Whether that implicit call suceeded or not has no
    bearing on whether a new rfkill class should register sucessfully or not.
    
    Bug reported by "kionez <kionez@anche.no>".
    
    Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
    Cc: Ivo van Doorn <IvDoorn@gmail.com>
    Cc: kionez <kionez@anche.no>

diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index aa7039d..7a560b7 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -501,17 +501,15 @@ static struct class rfkill_class = {
 
 static int rfkill_add_switch(struct rfkill *rfkill)
 {
-	int error;
-
 	mutex_lock(&rfkill_mutex);
 
-	error = rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0);
-	if (!error)
-		list_add_tail(&rfkill->node, &rfkill_list);
+	rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0);
+
+	list_add_tail(&rfkill->node, &rfkill_list);
 
 	mutex_unlock(&rfkill_mutex);
 
-	return error;
+	return 0;
 }
 
 static void rfkill_remove_switch(struct rfkill *rfkill)

--IS0zKkzwUGydFO0o--