diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-10-26 17:25:52 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-10-26 17:25:52 -0500 |
commit | 4f85ee5c9744e08225424184234cf2d5b129ecdc (patch) | |
tree | de19d01edf4262f6b11dc2e961e9f3d940bfc98d /src | |
parent | 078e2bdc2abcdd49f9caec1420debb49e85352e6 (diff) | |
download | ofono-4f85ee5c9744e08225424184234cf2d5b129ecdc.tar.bz2 |
Simplify logic in netreg_update
Diffstat (limited to 'src')
-rw-r--r-- | src/gprs.c | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -548,23 +548,24 @@ static void gprs_attach_callback(const struct ofono_error *error, void *data) static void gprs_netreg_update(struct ofono_gprs *gprs) { - int attach; - int operator_ok; + ofono_bool_t attach; - operator_ok = gprs->roaming_allowed || - (gprs->status != NETWORK_REGISTRATION_STATUS_ROAMING); + attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED; - attach = gprs->powered && operator_ok; + attach = attach || (gprs->roaming_allowed && + gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING); - if (gprs->driver_attached != attach && - !(gprs->flags & GPRS_FLAG_ATTACHING) && - !(attach && gprs->status == - NETWORK_REGISTRATION_STATUS_SEARCHING)) { - gprs->flags |= GPRS_FLAG_ATTACHING; + attach = attach && gprs->powered; - gprs->driver->set_attached(gprs, attach, gprs_attach_callback, - gprs); - } + if (gprs->attached == attach) + return; + + if (gprs->flags & GPRS_FLAG_ATTACHING) + return; + + gprs->flags |= GPRS_FLAG_ATTACHING; + + gprs->driver->set_attached(gprs, attach, gprs_attach_callback, gprs); } static void netreg_status_changed(int status, int lac, int ci, int tech, |