svn commit: r298612 - head/sys/dev/iwm

Adrian Chadd adrian at freebsd.org
Tue Apr 26 13:27:52 UTC 2016


it's a dirty habit I learnt from linux.

Seeing the '!!' says "it's always 1 or 0". I get into that habit so
the same thing happens when you do bit masking, eg:

do_stop = (foo & 0x10) ;

is 0x10 or 0, but

do_stop = !! (foo & 0x10);

is 1 or 0.



-adrian


On 25 April 2016 at 21:45, Ravi Pokala <rpokala at mac.com> wrote:
>> do_stop = !! (sc->sc_ic.ic_nrunning > 0);
>
> Why the double-negation? Isn't
>
>     do_stop = (sc->sc_ic.ic_nrunning > 0);
>
> equivalent?
>
> -Ravi (rpokala@)
>
>
>
> -----Original Message-----
> From: <owner-src-committers at freebsd.org> on behalf of Adrian Chadd <adrian at FreeBSD.org>
> Date: 2016-04-25, Monday at 21:40
> To: <src-committers at freebsd.org>, <svn-src-all at freebsd.org>, <svn-src-head at freebsd.org>
> Subject: svn commit: r298612 - head/sys/dev/iwm
>
>>Author: adrian
>>Date: Tue Apr 26 04:40:59 2016
>>New Revision: 298612
>>URL: https://svnweb.freebsd.org/changeset/base/298612
>>
>>Log:
>>  [iwm] implement suspend/resume through ieee80211_{suspend,resume}_all
>>
>>  This allows wifi to associate correctly after a suspend/resume cycle.
>>
>>  Yes, I'm using this now day to day.
>>
>>  Tested:
>>
>>  * Intel 7260AC, STA mode
>>
>>Modified:
>>  head/sys/dev/iwm/if_iwm.c
>>  head/sys/dev/iwm/if_iwmvar.h
>>
>>Modified: head/sys/dev/iwm/if_iwm.c
>>==============================================================================
>>--- head/sys/dev/iwm/if_iwm.c  Tue Apr 26 03:24:28 2016        (r298611)
>>+++ head/sys/dev/iwm/if_iwm.c  Tue Apr 26 04:40:59 2016        (r298612)
>>@@ -4934,6 +4934,8 @@ iwm_init_task(void *arg1)
>> static int
>> iwm_resume(device_t dev)
>> {
>>+      struct iwm_softc *sc = device_get_softc(dev);
>>+      int do_reinit = 0;
>>       uint16_t reg;
>>
>>       /* Clear device-specific "PCI retry timeout" register (41h). */
>>@@ -4941,17 +4943,33 @@ iwm_resume(device_t dev)
>>       pci_write_config(dev, 0x40, reg & ~0xff00, sizeof(reg));
>>       iwm_init_task(device_get_softc(dev));
>>
>>+      IWM_LOCK(sc);
>>+      if (sc->sc_flags & IWM_FLAG_DORESUME) {
>>+              sc->sc_flags &= ~IWM_FLAG_DORESUME;
>>+              do_reinit = 1;
>>+      }
>>+      IWM_UNLOCK(sc);
>>+
>>+      if (do_reinit)
>>+              ieee80211_resume_all(&sc->sc_ic);
>>+
>>       return 0;
>> }
>>
>> static int
>> iwm_suspend(device_t dev)
>> {
>>+      int do_stop = 0;
>>       struct iwm_softc *sc = device_get_softc(dev);
>>
>>-      if (sc->sc_ic.ic_nrunning > 0) {
>>+      do_stop = !! (sc->sc_ic.ic_nrunning > 0);
>>+
>>+      ieee80211_suspend_all(&sc->sc_ic);
>>+
>>+      if (do_stop) {
>>               IWM_LOCK(sc);
>>               iwm_stop(sc);
>>+              sc->sc_flags |= IWM_FLAG_DORESUME;
>>               IWM_UNLOCK(sc);
>>       }
>>
>>
>>Modified: head/sys/dev/iwm/if_iwmvar.h
>>==============================================================================
>>--- head/sys/dev/iwm/if_iwmvar.h       Tue Apr 26 03:24:28 2016        (r298611)
>>+++ head/sys/dev/iwm/if_iwmvar.h       Tue Apr 26 04:40:59 2016        (r298612)
>>@@ -405,6 +405,7 @@ struct iwm_softc {
>> #define IWM_FLAG_STOPPED      (1 << 2)
>> #define IWM_FLAG_RFKILL               (1 << 3)
>> #define IWM_FLAG_BUSY         (1 << 4)
>>+#define       IWM_FLAG_DORESUME       (1 << 5)
>>
>>       struct intr_config_hook sc_preinit_hook;
>>       struct callout          sc_watchdog_to;
>>
>


More information about the svn-src-head mailing list