samples: lora: drop device_get_binding

Use DEVICE_DT_GET.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2021-04-26 12:28:27 -07:00 committed by Carles Cufí
commit 2f576b9ada
2 changed files with 6 additions and 10 deletions

View file

@ -13,7 +13,6 @@
#define DEFAULT_RADIO_NODE DT_ALIAS(lora0)
BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_RADIO_NODE, okay),
"No default LoRa radio specified in DT");
#define DEFAULT_RADIO DT_LABEL(DEFAULT_RADIO_NODE)
#define MAX_DATA_LEN 255
@ -23,16 +22,15 @@ LOG_MODULE_REGISTER(lora_receive);
void main(void)
{
const struct device *lora_dev;
const struct device *lora_dev = DEVICE_DT_GET(DEFAULT_RADIO_NODE);
struct lora_modem_config config;
int ret, len;
uint8_t data[MAX_DATA_LEN] = {0};
int16_t rssi;
int8_t snr;
lora_dev = device_get_binding(DEFAULT_RADIO);
if (!lora_dev) {
LOG_ERR("%s Device not found", DEFAULT_RADIO);
if (!device_is_ready(lora_dev)) {
LOG_ERR("%s Device not ready", lora_dev->name);
return;
}

View file

@ -13,7 +13,6 @@
#define DEFAULT_RADIO_NODE DT_ALIAS(lora0)
BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_RADIO_NODE, okay),
"No default LoRa radio specified in DT");
#define DEFAULT_RADIO DT_LABEL(DEFAULT_RADIO_NODE)
#define MAX_DATA_LEN 10
@ -25,13 +24,12 @@ char data[MAX_DATA_LEN] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'};
void main(void)
{
const struct device *lora_dev;
const struct device *lora_dev = DEVICE_DT_GET(DEFAULT_RADIO_NODE);
struct lora_modem_config config;
int ret;
lora_dev = device_get_binding(DEFAULT_RADIO);
if (!lora_dev) {
LOG_ERR("%s Device not found", DEFAULT_RADIO);
if (!device_is_ready(lora_dev)) {
LOG_ERR("%s Device not ready", lora_dev->name);
return;
}