@@ -233,9 +233,7 @@ __subsystem struct ethphy_driver_api {
233
233
static inline int phy_configure_link (const struct device * dev , enum phy_link_speed speeds ,
234
234
enum phy_cfg_link_flag flags )
235
235
{
236
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
237
-
238
- if (api -> cfg_link == NULL ) {
236
+ if (DEVICE_API_GET (ethphy , dev )-> cfg_link == NULL ) {
239
237
return - ENOSYS ;
240
238
}
241
239
@@ -244,7 +242,7 @@ static inline int phy_configure_link(const struct device *dev, enum phy_link_spe
244
242
return - EINVAL ;
245
243
}
246
244
247
- return api -> cfg_link (dev , speeds , flags );
245
+ return DEVICE_API_GET ( ethphy , dev ) -> cfg_link (dev , speeds , flags );
248
246
}
249
247
250
248
/**
@@ -262,13 +260,11 @@ static inline int phy_configure_link(const struct device *dev, enum phy_link_spe
262
260
*/
263
261
static inline int phy_get_link_state (const struct device * dev , struct phy_link_state * state )
264
262
{
265
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
266
-
267
- if (api -> get_link == NULL ) {
263
+ if (DEVICE_API_GET (ethphy , dev )-> get_link == NULL ) {
268
264
return - ENOSYS ;
269
265
}
270
266
271
- return api -> get_link (dev , state );
267
+ return DEVICE_API_GET ( ethphy , dev ) -> get_link (dev , state );
272
268
}
273
269
274
270
/**
@@ -292,13 +288,11 @@ static inline int phy_get_link_state(const struct device *dev, struct phy_link_s
292
288
static inline int phy_link_callback_set (const struct device * dev , phy_callback_t callback ,
293
289
void * user_data )
294
290
{
295
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
296
-
297
- if (api -> link_cb_set == NULL ) {
291
+ if (DEVICE_API_GET (ethphy , dev )-> link_cb_set == NULL ) {
298
292
return - ENOSYS ;
299
293
}
300
294
301
- return api -> link_cb_set (dev , callback , user_data );
295
+ return DEVICE_API_GET ( ethphy , dev ) -> link_cb_set (dev , callback , user_data );
302
296
}
303
297
304
298
/**
@@ -315,13 +309,11 @@ static inline int phy_link_callback_set(const struct device *dev, phy_callback_t
315
309
*/
316
310
static inline int phy_read (const struct device * dev , uint16_t reg_addr , uint32_t * value )
317
311
{
318
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
319
-
320
- if (api -> read == NULL ) {
312
+ if (DEVICE_API_GET (ethphy , dev )-> read == NULL ) {
321
313
return - ENOSYS ;
322
314
}
323
315
324
- return api -> read (dev , reg_addr , value );
316
+ return DEVICE_API_GET ( ethphy , dev ) -> read (dev , reg_addr , value );
325
317
}
326
318
327
319
/**
@@ -338,13 +330,11 @@ static inline int phy_read(const struct device *dev, uint16_t reg_addr, uint32_t
338
330
*/
339
331
static inline int phy_write (const struct device * dev , uint16_t reg_addr , uint32_t value )
340
332
{
341
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
342
-
343
- if (api -> write == NULL ) {
333
+ if (DEVICE_API_GET (ethphy , dev )-> write == NULL ) {
344
334
return - ENOSYS ;
345
335
}
346
336
347
- return api -> write (dev , reg_addr , value );
337
+ return DEVICE_API_GET ( ethphy , dev ) -> write (dev , reg_addr , value );
348
338
}
349
339
350
340
/**
@@ -363,13 +353,11 @@ static inline int phy_write(const struct device *dev, uint16_t reg_addr, uint32_
363
353
static inline int phy_read_c45 (const struct device * dev , uint8_t devad , uint16_t regad ,
364
354
uint16_t * data )
365
355
{
366
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
367
-
368
- if (api -> read_c45 == NULL ) {
356
+ if (DEVICE_API_GET (ethphy , dev )-> read_c45 == NULL ) {
369
357
return - ENOSYS ;
370
358
}
371
359
372
- return api -> read_c45 (dev , devad , regad , data );
360
+ return DEVICE_API_GET ( ethphy , dev ) -> read_c45 (dev , devad , regad , data );
373
361
}
374
362
375
363
/**
@@ -388,13 +376,11 @@ static inline int phy_read_c45(const struct device *dev, uint8_t devad, uint16_t
388
376
static inline int phy_write_c45 (const struct device * dev , uint8_t devad , uint16_t regad ,
389
377
uint16_t data )
390
378
{
391
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
392
-
393
- if (api -> write_c45 == NULL ) {
379
+ if (DEVICE_API_GET (ethphy , dev )-> write_c45 == NULL ) {
394
380
return - ENOSYS ;
395
381
}
396
382
397
- return api -> write_c45 (dev , devad , regad , data );
383
+ return DEVICE_API_GET ( ethphy , dev ) -> write_c45 (dev , devad , regad , data );
398
384
}
399
385
400
386
/**
@@ -410,13 +396,11 @@ static inline int phy_write_c45(const struct device *dev, uint8_t devad, uint16_
410
396
*/
411
397
static inline int phy_set_plca_cfg (const struct device * dev , struct phy_plca_cfg * plca_cfg )
412
398
{
413
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
414
-
415
- if (api -> set_plca_cfg == NULL ) {
399
+ if (DEVICE_API_GET (ethphy , dev )-> set_plca_cfg == NULL ) {
416
400
return - ENOSYS ;
417
401
}
418
402
419
- return api -> set_plca_cfg (dev , plca_cfg );
403
+ return DEVICE_API_GET ( ethphy , dev ) -> set_plca_cfg (dev , plca_cfg );
420
404
}
421
405
422
406
/**
@@ -432,13 +416,11 @@ static inline int phy_set_plca_cfg(const struct device *dev, struct phy_plca_cfg
432
416
*/
433
417
static inline int phy_get_plca_cfg (const struct device * dev , struct phy_plca_cfg * plca_cfg )
434
418
{
435
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
436
-
437
- if (api -> get_plca_cfg == NULL ) {
419
+ if (DEVICE_API_GET (ethphy , dev )-> get_plca_cfg == NULL ) {
438
420
return - ENOSYS ;
439
421
}
440
422
441
- return api -> get_plca_cfg (dev , plca_cfg );
423
+ return DEVICE_API_GET ( ethphy , dev ) -> get_plca_cfg (dev , plca_cfg );
442
424
}
443
425
444
426
/**
@@ -454,13 +436,11 @@ static inline int phy_get_plca_cfg(const struct device *dev, struct phy_plca_cfg
454
436
*/
455
437
static inline int phy_get_plca_sts (const struct device * dev , bool * plca_status )
456
438
{
457
- const struct ethphy_driver_api * api = (const struct ethphy_driver_api * )dev -> api ;
458
-
459
- if (api -> get_plca_sts == NULL ) {
439
+ if (DEVICE_API_GET (ethphy , dev )-> get_plca_sts == NULL ) {
460
440
return - ENOSYS ;
461
441
}
462
442
463
- return api -> get_plca_sts (dev , plca_status );
443
+ return DEVICE_API_GET ( ethphy , dev ) -> get_plca_sts (dev , plca_status );
464
444
}
465
445
466
446
#ifdef __cplusplus
0 commit comments