1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #11153 from kaspar030/fix_encx24j600_netopt_linkstate

drivers/encx24j600: lock dev in netopt get()
This commit is contained in:
Koen Zandberg 2019-03-11 12:52:27 +01:00 committed by GitHub
commit f4bb315db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -386,13 +386,18 @@ static int _get(netdev_t *dev, netopt_t opt, void *value, size_t max_len)
}
break;
case NETOPT_LINK_CONNECTED:
if (reg_get((encx24j600_t *)dev, ENC_ESTAT) & ENC_PHYLNK) {
*((netopt_enable_t *)value) = NETOPT_ENABLE;
{
encx24j600_t * encdev = (encx24j600_t *) dev;
lock(encdev);
if (reg_get(encdev, ENC_ESTAT) & ENC_PHYLNK) {
*((netopt_enable_t *)value) = NETOPT_ENABLE;
}
else {
*((netopt_enable_t *)value) = NETOPT_DISABLE;
}
unlock(encdev);
return sizeof(netopt_enable_t);
}
else {
*((netopt_enable_t *)value) = NETOPT_DISABLE;
}
return sizeof(netopt_enable_t);
default:
res = netdev_eth_get(dev, opt, value, max_len);
break;