Changeset 47986


Ignore:
Timestamp:
2015-12-23T16:45:36+01:00 (2 years ago)
Author:
rmilecki
Message:

ledtrig-netdev: switch rwlock to spinlock

Read/write lock was adding useless complexity, there wasn't any real
gain in case of this driver.
Also switch to _bh variants to avoid deadlocks.

Signed-off-by: Rafał Miłecki <zajec5@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/generic/files/drivers/leds/ledtrig-netdev.c

    r47962 r47986  
    6969 
    7070struct led_netdev_data { 
    71         rwlock_t lock; 
     71        spinlock_t lock; 
    7272 
    7373        struct timer_list timer; 
     
    103103        struct led_netdev_data *trigger_data = led_cdev->trigger_data; 
    104104 
    105         read_lock(&trigger_data->lock); 
     105        spin_lock_bh(&trigger_data->lock); 
    106106        sprintf(buf, "%s\n", trigger_data->device_name); 
    107         read_unlock(&trigger_data->lock); 
     107        spin_unlock_bh(&trigger_data->lock); 
    108108 
    109109        return strlen(buf) + 1; 
     
    119119                return -EINVAL; 
    120120 
    121         write_lock(&trigger_data->lock); 
     121        spin_lock_bh(&trigger_data->lock); 
    122122 
    123123        strcpy(trigger_data->device_name, buf); 
     
    133133        } 
    134134 
    135         write_unlock(&trigger_data->lock); 
     135        spin_unlock_bh(&trigger_data->lock); 
    136136        return size; 
    137137} 
     
    145145        struct led_netdev_data *trigger_data = led_cdev->trigger_data; 
    146146 
    147         read_lock(&trigger_data->lock); 
     147        spin_lock_bh(&trigger_data->lock); 
    148148 
    149149        if (trigger_data->mode == 0) { 
     
    159159        } 
    160160 
    161         read_unlock(&trigger_data->lock); 
     161        spin_unlock_bh(&trigger_data->lock); 
    162162 
    163163        return strlen(buf)+1; 
     
    200200                return -EINVAL; 
    201201 
    202         write_lock(&trigger_data->lock); 
     202        spin_lock_bh(&trigger_data->lock); 
    203203        trigger_data->mode = new_mode; 
    204204        set_baseline_state(trigger_data); 
    205         write_unlock(&trigger_data->lock); 
     205        spin_unlock_bh(&trigger_data->lock); 
    206206 
    207207        return size; 
     
    216216        struct led_netdev_data *trigger_data = led_cdev->trigger_data; 
    217217 
    218         read_lock(&trigger_data->lock); 
     218        spin_lock_bh(&trigger_data->lock); 
    219219        sprintf(buf, "%u\n", jiffies_to_msecs(trigger_data->interval)); 
    220         read_unlock(&trigger_data->lock); 
     220        spin_unlock_bh(&trigger_data->lock); 
    221221 
    222222        return strlen(buf) + 1; 
     
    238238        /* impose some basic bounds on the timer interval */ 
    239239        if (count == size && value >= 5 && value <= 10000) { 
    240                 write_lock(&trigger_data->lock); 
     240                spin_lock_bh(&trigger_data->lock); 
    241241                trigger_data->interval = msecs_to_jiffies(value); 
    242242                set_baseline_state(trigger_data); /* resets timer */ 
    243                 write_unlock(&trigger_data->lock); 
     243                spin_unlock_bh(&trigger_data->lock); 
    244244                ret = count; 
    245245        } 
     
    260260                return NOTIFY_DONE; 
    261261 
    262         write_lock(&trigger_data->lock); 
     262        spin_lock_bh(&trigger_data->lock); 
    263263 
    264264        if (strcmp(dev->name, trigger_data->device_name)) 
     
    286286 
    287287done: 
    288         write_unlock(&trigger_data->lock); 
     288        spin_unlock_bh(&trigger_data->lock); 
    289289        return NOTIFY_DONE; 
    290290} 
     
    298298        struct rtnl_link_stats64 temp; 
    299299 
    300         write_lock(&trigger_data->lock); 
     300        spin_lock(&trigger_data->lock); 
    301301 
    302302        if (!trigger_data->link_up || !trigger_data->net_dev || (trigger_data->mode & (MODE_TX | MODE_RX)) == 0) { 
     
    337337 
    338338no_restart: 
    339         write_unlock(&trigger_data->lock); 
     339        spin_unlock(&trigger_data->lock); 
    340340} 
    341341 
     
    349349                return; 
    350350 
    351         rwlock_init(&trigger_data->lock); 
     351        spin_lock_init(&trigger_data->lock); 
    352352 
    353353        trigger_data->notifier.notifier_call = netdev_trig_notify; 
     
    400400                device_remove_file(led_cdev->dev, &dev_attr_interval); 
    401401 
    402                 write_lock(&trigger_data->lock); 
     402                spin_lock_bh(&trigger_data->lock); 
    403403 
    404404                if (trigger_data->net_dev) { 
     
    407407                } 
    408408 
    409                 write_unlock(&trigger_data->lock); 
     409                spin_unlock_bh(&trigger_data->lock); 
    410410 
    411411                del_timer_sync(&trigger_data->timer); 
Note: See TracChangeset for help on using the changeset viewer.