mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maciej Rutecki <maciej.rutecki@gmail.com>
To: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>, Frans Pop <elendil@planet.nl>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	linux acpi <linux-acpi@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFT] hp-wmi: improved rfkill support for wifi
Date: Mon, 20 Jul 2009 21:54:54 +0200	[thread overview]
Message-ID: <8db1092f0907201254m2be66477k6ec2f447bfad9f73@mail.gmail.com> (raw)
In-Reply-To: <4A64A50D.5040401@tuffmail.co.uk>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 16372 bytes --]

2009/7/20 Alan Jenkins <alan-jenkins@tuffmail.co.uk>:>> ...and here's the version that remembers to register the bluetooth.  I> reviewed the patch again; hopefully that's the last dumb error.[...]
2.6.31-rc3+ patches:http://lkml.org/lkml/2009/7/18/131http://lkml.org/lkml/2009/7/10/339+ patch below:
> diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c> index 517ac47..adb26d3 100644> --- a/drivers/platform/x86/hp-wmi.c> +++ b/drivers/platform/x86/hp-wmi.c> @@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");>  #define HPWMI_WIRELESS_QUERY 0x5>  #define HPWMI_HOTKEY_QUERY 0xc>> +enum hp_wmi_radio {> +       HPWMI_WIFI = 0,> +       HPWMI_BLUETOOTH = 1,> +       HPWMI_WWAN = 2,> +};> +>  static int __init hp_wmi_bios_setup(struct platform_device *device);>  static int __exit hp_wmi_bios_remove(struct platform_device *device);>  static int hp_wmi_resume_handler(struct platform_device *device);> @@ -170,8 +176,8 @@ static int hp_wmi_tablet_state(void)>>  static int hp_wmi_set_block(void *data, bool blocked)>  {> -       unsigned long b = (unsigned long) data;> -       int query = BIT(b + 8) | ((!blocked) << b);> +       enum hp_wmi_radio r = (enum hp_wmi_radio) data;> +       int query = BIT(r + 8) | ((!blocked) << r);>>        return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);>  }> @@ -180,41 +186,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {>        .set_block = hp_wmi_set_block,>  };>> -static bool hp_wmi_wifi_sw_state(void)> +static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)>  {>        int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);> +       int mask = 0x200 << (r * 8);>> -       if (wireless & 0x200)> +       if (wireless & mask)>                return false;>        else>                return true;>  }>> -static bool hp_wmi_wifi_hw_state(void)> +static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)>  {>        int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);> +       int mask = 0x800 << (r * 8);>> -       if (wireless & 0x800)> -               return false;> -       else> -               return true;> -}> -> -static bool hp_wmi_bluetooth_state(void)> -{> -       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);> -> -       if (wireless & 0x10000)> -               return false;> -       else> -               return true;> -}> -> -static bool hp_wmi_wwan_state(void)> -{> -       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);> -> -       if (wireless & 0x1000000)> +       if (wireless & mask)>                return false;>        else>                return true;> @@ -339,50 +327,55 @@ static void hp_wmi_notify(u32 value, void *context)>        struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };>        static struct key_entry *key;>        union acpi_object *obj;> +       int eventcode;>>        wmi_get_event_data(value, &response);>>        obj = (union acpi_object *)response.pointer;>> -       if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {> -               int eventcode = *((u8 *) obj->buffer.pointer);> -               if (eventcode == 0x4)> -                       eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,> -                                                        0);> -               key = hp_wmi_get_entry_by_scancode(eventcode);> -               if (key) {> -                       switch (key->type) {> -                       case KE_KEY:> -                               input_report_key(hp_wmi_input_dev,> -                                                key->keycode, 1);> -                               input_sync(hp_wmi_input_dev);> -                               input_report_key(hp_wmi_input_dev,> -                                                key->keycode, 0);> -                               input_sync(hp_wmi_input_dev);> -                               break;> -                       }> -               } else if (eventcode == 0x1) {> -                       input_report_switch(hp_wmi_input_dev, SW_DOCK,> -                                           hp_wmi_dock_state());> -                       input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,> -                                           hp_wmi_tablet_state());> +       if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {> +               printk(KERN_INFO "HP WMI: Unknown response received\n");> +               return;> +       }> +> +       eventcode = *((u8 *) obj->buffer.pointer);> +       if (eventcode == 0x4)> +               eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,> +                                               0);> +       key = hp_wmi_get_entry_by_scancode(eventcode);> +       if (key) {> +               switch (key->type) {> +               case KE_KEY:> +                       input_report_key(hp_wmi_input_dev,> +                                        key->keycode, 1);> +                       input_sync(hp_wmi_input_dev);> +                       input_report_key(hp_wmi_input_dev,> +                                        key->keycode, 0);>                        input_sync(hp_wmi_input_dev);> -               } else if (eventcode == 0x5) {> -                       if (wifi_rfkill)> -                               rfkill_set_states(wifi_rfkill,> -                                                 hp_wmi_wifi_sw_state(),> -                                                 hp_wmi_wifi_hw_state());> -                       if (bluetooth_rfkill)> -                               rfkill_set_sw_state(bluetooth_rfkill,> -                                                   hp_wmi_bluetooth_state());> -                       if (wwan_rfkill)> -                               rfkill_set_sw_state(wwan_rfkill,> -                                                   hp_wmi_wwan_state());> -               } else> -                       printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",> -                              eventcode);> +                       break;> +               }> +       } else if (eventcode == 0x1) {> +               input_report_switch(hp_wmi_input_dev, SW_DOCK,> +                                   hp_wmi_dock_state());> +               input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,> +                                   hp_wmi_tablet_state());> +               input_sync(hp_wmi_input_dev);> +       } else if (eventcode == 0x5) {> +               if (wifi_rfkill)> +                       rfkill_set_states(wifi_rfkill,> +                                         hp_wmi_get_sw_state(HPWMI_WIFI),> +                                         hp_wmi_get_hw_state(HPWMI_WIFI));> +               if (bluetooth_rfkill)> +                       rfkill_set_states(bluetooth_rfkill,> +                                         hp_wmi_get_sw_state(HPWMI_BLUETOOTH),> +                                         hp_wmi_get_hw_state(HPWMI_BLUETOOTH));> +               if (wwan_rfkill)> +                       rfkill_set_states(wwan_rfkill,> +                                         hp_wmi_get_sw_state(HPWMI_WWAN),> +                                         hp_wmi_get_hw_state(HPWMI_WWAN));>        } else> -               printk(KERN_INFO "HP WMI: Unknown response received\n");> +               printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",> +                       eventcode);>  }>>  static int __init hp_wmi_input_setup(void)> @@ -461,11 +454,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)>                wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,>                                           RFKILL_TYPE_WLAN,>                                           &hp_wmi_rfkill_ops,> -                                          (void *) 0);> +                                          (void *) HPWMI_WIFI);>                rfkill_init_sw_state(wifi_rfkill,> -                                    hp_wmi_wifi_sw_state());> +                                    hp_wmi_get_sw_state(HPWMI_WIFI));>                rfkill_set_hw_state(wifi_rfkill,> -                                   hp_wmi_wifi_hw_state());> +                                   hp_wmi_get_hw_state(HPWMI_WIFI));>                err = rfkill_register(wifi_rfkill);>                if (err)>                        goto register_wifi_error;> @@ -475,7 +468,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)>                bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,>                                                RFKILL_TYPE_BLUETOOTH,>                                                &hp_wmi_rfkill_ops,> -                                               (void *) 1);> +                                               (void *) HPWMI_BLUETOOTH);> +               rfkill_init_sw_state(bluetooth_rfkill,> +                                    hp_wmi_get_sw_state(HPWMI_BLUETOOTH));> +               rfkill_set_hw_state(bluetooth_rfkill,> +                                   hp_wmi_get_hw_state(HPWMI_BLUETOOTH));>                err = rfkill_register(bluetooth_rfkill);>                if (err)>                        goto register_bluetooth_error;> @@ -485,7 +482,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)>                wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,>                                           RFKILL_TYPE_WWAN,>                                           &hp_wmi_rfkill_ops,> -                                          (void *) 2);> +                                          (void *) HPWMI_WWAN);> +               rfkill_init_sw_state(wwan_rfkill,> +                                    hp_wmi_get_sw_state(HPWMI_WWAN));> +               rfkill_set_hw_state(wwan_rfkill,> +                                   hp_wmi_get_hw_state(HPWMI_WWAN));>                err = rfkill_register(wwan_rfkill);>                if (err)>                        goto register_wwan_err;> @@ -541,9 +542,18 @@ static int hp_wmi_resume_handler(struct platform_device *device)>                            hp_wmi_tablet_state());>        input_sync(hp_wmi_input_dev);>> -       rfkill_set_states(wifi_rfkill,> -                         hp_wmi_wifi_sw_state(),> -                         hp_wmi_wifi_hw_state());> +       if (wifi_rfkill)> +               rfkill_set_states(wifi_rfkill,> +                                 hp_wmi_get_sw_state(HPWMI_WIFI),> +                                 hp_wmi_get_hw_state(HPWMI_WIFI));> +       if (bluetooth_rfkill)> +               rfkill_set_states(bluetooth_rfkill,> +                                 hp_wmi_get_sw_state(HPWMI_BLUETOOTH),> +                                 hp_wmi_get_hw_state(HPWMI_BLUETOOTH));> +       if (wwan_rfkill)> +               rfkill_set_states(wwan_rfkill,> +                                 hp_wmi_get_sw_state(HPWMI_WWAN),> +                                 hp_wmi_get_hw_state(HPWMI_WWAN));>>        return 0;>  }>>>
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list0: phy0: Wireless LAN        Soft blocked: yes        Hard blocked: yes1: hp-wifi: Wireless LAN        Soft blocked: yes        Hard blocked: no2: hp-bluetooth: Bluetooth        Soft blocked: yes        Hard blocked: noroot@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 0root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list0: phy0: Wireless LAN        Soft blocked: no        Hard blocked: yes1: hp-wifi: Wireless LAN        Soft blocked: yes        Hard blocked: no2: hp-bluetooth: Bluetooth        Soft blocked: yes        Hard blocked: noroot@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 1root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list0: phy0: Wireless LAN        Soft blocked: no        Hard blocked: no1: hp-wifi: Wireless LAN        Soft blocked: no        Hard blocked: no2: hp-bluetooth: Bluetooth        Soft blocked: yes        Hard blocked: noroot@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 2root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list0: phy0: Wireless LAN        Soft blocked: no        Hard blocked: no1: hp-wifi: Wireless LAN        Soft blocked: no        Hard blocked: no2: hp-bluetooth: Bluetooth        Soft blocked: no        Hard blocked: no3: hci0: Bluetooth        Soft blocked: yes        Hard blocked: noroot@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 3root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list0: phy0: Wireless LAN        Soft blocked: no        Hard blocked: no1: hp-wifi: Wireless LAN        Soft blocked: no        Hard blocked: no2: hp-bluetooth: Bluetooth        Soft blocked: no        Hard blocked: no3: hci0: Bluetooth        Soft blocked: no        Hard blocked: noroot@gumis:/home/maciek/zrodelka/rfkill/rfkill# hciconfighci0:   Type: USB        BD Address: 00:16:41:88:A0:1B ACL MTU: 1017:8 SCO MTU: 64:8        DOWN        RX bytes:318 acl:0 sco:0 events:6 errors:0        TX bytes:27 acl:0 sco:0 commands:9 errors:0
Works OK. Thanks :-)
During compile I have got:CC [M]  drivers/platform/x86/hp-wmi.odrivers/platform/x86/hp-wmi.c: In function ‘hp_wmi_bios_setup’:drivers/platform/x86/hp-wmi.c:460: warning: ignoring return value of‘rfkill_set_hw_state’, declared with attribute warn_unused_resultdrivers/platform/x86/hp-wmi.c:474: warning: ignoring return value of‘rfkill_set_hw_state’, declared with attribute warn_unused_resultdrivers/platform/x86/hp-wmi.c:488: warning: ignoring return value of‘rfkill_set_hw_state’, declared with attribute warn_unused_result
root@gumis:/home/maciek# gcc -vUsing built-in specs.Target: i486-linux-gnuConfigured with: ../src/configure -v --with-pkgversion='Debian4.3.3-13' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr--enable-shared --enable-multiarch --with-system-zlib--libexecdir=/usr/lib --without-included-gettext--enable-threads=posix --enable-nls--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc--enable-mpfr --enable-targets=all --with-tune=generic--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu--target=i486-linux-gnuThread model: posixgcc version 4.3.3 (Debian 4.3.3-13)
Regards-- Maciej Ruteckihttp://www.maciek.unixy.plÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

  reply	other threads:[~2009-07-20 19:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-18 16:55 Alan Jenkins
2009-07-18 17:03 ` Matthew Garrett
2009-07-18 18:55 ` Maciej Rutecki
2009-07-18 20:46   ` Alan Jenkins
2009-07-18 21:37     ` Corentin Chary
2009-07-19  8:15       ` Maciej Rutecki
2009-07-19  7:28     ` Maciej Rutecki
2009-07-19 17:21       ` Alan Jenkins
2009-07-19 18:10         ` Maciej Rutecki
2009-07-19 18:24           ` Alan Jenkins
2009-07-19 19:08             ` Maciej Rutecki
2009-07-20 17:10               ` Alan Jenkins
2009-07-20 19:54                 ` Maciej Rutecki [this message]
2009-07-20 20:08                   ` Alan Jenkins
2009-07-19 18:25           ` Matthew Garrett
2009-07-19 19:08             ` Maciej Rutecki

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=8db1092f0907201254m2be66477k6ec2f447bfad9f73@mail.gmail.com \
    --to=maciej.rutecki@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=elendil@planet.nl \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    /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

Powered by JetHome