Changeset 8a64320e in mainline for uspace/lib/drv


Ignore:
Timestamp:
2015-04-23T23:40:14Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dcba819
Parents:
09044cb
Message:

pre-merge coding style cleanup and code review

Location:
uspace/lib/drv
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_ieee80211.c

    r09044cb r8a64320e  
    4040#include <inet/dhcp.h>
    4141#include <inet/inetcfg.h>
    42 
    4342#include "ops/ieee80211.h"
    4443#include "ieee80211_iface.h"
    4544#include "nic_iface.h"
    4645
    47 #define MAX_STRING_SIZE 32
     46#define MAX_STRING_SIZE  32
    4847
    4948/** IEEE 802.11 RPC functions IDs. */
     
    5655/** Get scan results from IEEE 802.11 device
    5756 *
    58  * @param[in] dev_sess Device session.
    59  * @param[out] results Structure where to put scan results.
     57 * @param[in]  dev_sess Device session.
     58 * @param[out] results  Structure where to put scan results.
    6059 *
    6160 * @return EOK If the operation was successfully completed,
    62  * negative error code otherwise.
    63  */
    64 int ieee80211_get_scan_results(async_sess_t *dev_sess,
    65         ieee80211_scan_results_t *results, bool now)
     61 *         negative error code otherwise.
     62 *
     63 */
     64int ieee80211_get_scan_results(async_sess_t *dev_sess,
     65    ieee80211_scan_results_t *results, bool now)
    6666{
    6767        assert(results);
     
    7171        aid_t aid = async_send_2(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE),
    7272            IEEE80211_GET_SCAN_RESULTS, now, NULL);
    73         int rc = async_data_read_start(exch, results, sizeof(ieee80211_scan_results_t));
     73        int rc = async_data_read_start(exch, results,
     74            sizeof(ieee80211_scan_results_t));
    7475        async_exchange_end(exch);
    75 
     76       
    7677        sysarg_t res;
    7778        async_wait_for(aid, &res);
     
    7980        if(res != EOK)
    8081                return (int) res;
    81         else
    82                 return rc;
     82       
     83        return rc;
    8384}
    8485
    8586static bool mac_matches(uint8_t *mac1, uint8_t *mac2)
    8687{
    87         for(size_t i = 0; i < ETH_ADDR; i++) {
    88                 if(mac1[i] != mac2[i])
     88        for (size_t i = 0; i < ETH_ADDR; i++) {
     89                if (mac1[i] != mac2[i])
    8990                        return false;
    9091        }
     
    108109                        return -1;
    109110               
    110                 if(mac_matches(mac, link_info.mac_addr)) {
     111                if (mac_matches(mac, link_info.mac_addr))
    111112                        return link_list[i];
    112                 }
    113113        }
    114114       
     
    118118/** Connect to specified network.
    119119 *
    120  * @param[in] dev_sess Device session.
     120 * @param[in] dev_sess   Device session.
    121121 * @param[in] ssid_start Network SSID prefix.
    122  * @param[in] password Network password (pass empty string if not needed).
     122 * @param[in] password   Network password (pass empty string if not needed).
    123123 *
    124124 * @return EOK If the operation was successfully completed,
    125  * negative error code otherwise.
     125 *         negative error code otherwise.
     126 *
    126127 */
    127128int ieee80211_connect(async_sess_t *dev_sess, char *ssid_start, char *password)
     
    136137            IEEE80211_CONNECT, NULL);
    137138       
    138         sysarg_t rc = async_data_write_start(exch, ssid_start, 
    139                 str_size(ssid_start) + 1);
     139        sysarg_t rc = async_data_write_start(exch, ssid_start,
     140            str_size(ssid_start) + 1);
    140141        if (rc != EOK) {
    141142                async_exchange_end(exch);
     
    144145                if (rc_orig == EOK)
    145146                        return (int) rc;
    146                 else
    147                         return (int) rc_orig;
    148         }
    149        
    150         if(password == NULL) {
     147               
     148                return (int) rc_orig;
     149        }
     150       
     151        // FIXME: Typecasting string literal
     152        if (password == NULL)
    151153                password = (char *) "";
    152         }
    153154       
    154155        rc = async_data_write_start(exch, password, str_size(password) + 1);
     
    159160                if (rc_orig == EOK)
    160161                        return (int) rc;
    161                 else
    162                         return (int) rc_orig;
     162               
     163                return (int) rc_orig;
    163164        }
    164165       
    165166        async_exchange_end(exch);
    166 
     167       
    167168        async_wait_for(aid, &rc);
    168169        if (rc != EOK)
     
    176177       
    177178        sysarg_t link_id = get_link_id(wifi_mac.address);
    178         if(link_id == ((sysarg_t) -1))
     179        if (link_id == ((sysarg_t) -1))
    179180                return EINVAL;
    180181       
     
    189190 *
    190191 * @return EOK If the operation was successfully completed,
    191  * negative error code otherwise.
     192 *         negative error code otherwise.
     193 *
    192194 */
    193195int ieee80211_disconnect(async_sess_t *dev_sess)
     
    198200        async_exchange_end(exch);
    199201       
    200         if(rc != EOK)
     202        if (rc != EOK)
    201203                return rc;
    202204       
     
    227229                        return rc;
    228230               
    229                 if(mac_matches(wifi_mac.address, link_info.mac_addr)) {
    230                         if(str_test_prefix(addr_info.name, "dhcp")) {
     231                if (mac_matches(wifi_mac.address, link_info.mac_addr)) {
     232                        if (str_test_prefix(addr_info.name, "dhcp")) {
    231233                                rc = inetcfg_addr_delete(addr_list[i]);
    232                                 if(rc != EOK)
     234                                if (rc != EOK)
    233235                                        return rc;
     236                               
    234237                                break;
    235238                        }
     
    237240        }
    238241       
    239         /* 
     242        /*
    240243         * TODO: At this moment there can be only one DHCP route,
    241244         * so it must be reimplemented after this limitation will be
     
    252255                        return rc;
    253256               
    254                 if(str_test_prefix(route_info.name, "dhcp")) {
     257                if (str_test_prefix(route_info.name, "dhcp")) {
    255258                        rc = inetcfg_sroute_delete(route_list[i]);
    256                         if(rc != EOK)
     259                        if (rc != EOK)
    257260                                return rc;
     261                       
    258262                        break;
    259263                }
  • uspace/lib/drv/include/ieee80211_iface.h

    r09044cb r8a64320e  
    2727 */
    2828
    29  /** @addtogroup libc
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3939#include <async.h>
    4040
    41 extern int ieee80211_get_scan_results(async_sess_t *, 
    42         ieee80211_scan_results_t *, bool);
     41extern int ieee80211_get_scan_results(async_sess_t *,
     42    ieee80211_scan_results_t *, bool);
    4343extern int ieee80211_connect(async_sess_t *, char *, char *);
    4444extern int ieee80211_disconnect(async_sess_t *);
  • uspace/lib/drv/include/ops/ieee80211.h

    r09044cb r8a64320e  
    4242/** IEEE 802.11 interface functions definition. */
    4343typedef struct ieee80211_iface {
    44         /**
    45          * Fetch scan results from IEEE 802.11 device.
    46          *
    47          * @param fun IEEE 802.11 function.
     44        /** Fetch scan results from IEEE 802.11 device.
     45         *
     46         * @param fun     IEEE 802.11 function.
    4847         * @param results Structure where to put scan results.
    49          * @param now Whether to initiate scan immediately.
    50          * 
     48         * @param now     Whether to initiate scan immediately.
     49         *
    5150         * @return EOK if succeed, negative error code otherwise.
     51         *
    5252         */
    5353        int (*get_scan_results)(ddf_fun_t *, ieee80211_scan_results_t *, bool);
    5454       
    55         /**
    56          * Connect IEEE 802.11 device to specified network.
     55        /** Connect IEEE 802.11 device to specified network.
    5756         *
    58          * @param fun IEEE 802.11 function.
    59          * @param ssid Network SSID.
     57         * @param fun      IEEE 802.11 function.
     58         * @param ssid     Network SSID.
    6059         * @param password Network password (empty string if not needed).
    61          * 
     60         *
    6261         * @return EOK if succeed, negative error code otherwise.
     62         *
    6363         */
    6464        int (*connect)(ddf_fun_t *, char *, char *);
    6565       
    66         /**
    67          * Disconnect IEEE 802.11 device from network.
     66        /** Disconnect IEEE 802.11 device from network.
    6867         *
    6968         * @param fun IEEE 802.11 function.
    70          * 
     69         *
    7170         * @return EOK if succeed, negative error code otherwise.
     71         *
    7272         */
    7373        int (*disconnect)(ddf_fun_t *);
Note: See TracChangeset for help on using the changeset viewer.