blob: 96ceddade6b1ad98f8a8126267ff07f0257f3638 [file] [log] [blame]
Michael Niewöhnerdbb667a2020-12-11 21:26:02 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <console/console.h>
4#include <device/device.h>
5#include <device/gpio.h>
Elyes Haouas04c3b5a2022-10-07 10:08:05 +02006#include <stddef.h>
Michael Niewöhnerdbb667a2020-12-11 21:26:02 +01007
8const struct gpio_operations *dev_get_gpio_ops(struct device *dev)
9{
10 if (!dev) {
11 printk(BIOS_ERR, "Could not get gpio operations, device is NULL.");
12 return NULL;
13 } else if (!dev->ops) {
14 printk(BIOS_ERR, "Could not get gpio operations, dev->ops is NULL.");
15 return NULL;
16 } else if (!dev->ops->ops_gpio) {
17 printk(BIOS_ERR, "Could not get gpio operations, ops_gpio is NULL.");
18 return NULL;
19 }
20
21 return dev->ops->ops_gpio;
22}