aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.h
blob: caa6fdf25bb1df69fd2a2fb0b1885f12884f9754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2023 Ideas On Board Oy
 */

#ifndef _VCHIQ_DEVICE_H
#define _VCHIQ_DEVICE_H

#include <linux/device.h>
#include <linux/mod_devicetable.h>

struct vchiq_device {
	struct device dev;
};

struct vchiq_driver {
	int		(*probe)(struct vchiq_device *device);
	void		(*remove)(struct vchiq_device *device);
	int		(*resume)(struct vchiq_device *device);
	int		(*suspend)(struct vchiq_device *device,
				   pm_message_t state);

	const struct vchiq_device_id *id_table;
	struct device_driver driver;
};

static inline struct vchiq_device *to_vchiq_device(struct device *d)
{
	return container_of(d, struct vchiq_device, dev);
}

static inline struct vchiq_driver *to_vchiq_driver(struct device_driver *d)
{
	return container_of(d, struct vchiq_driver, driver);
}

extern struct bus_type vchiq_bus_type;

struct vchiq_device *
vchiq_device_register(struct device *parent, const char *name);
void vchiq_device_unregister(struct vchiq_device *dev);

int vchiq_driver_register(struct vchiq_driver *vchiq_drv);
void vchiq_driver_unregister(struct vchiq_driver *vchiq_drv);

/**
 * module_vchiq_driver() - Helper macro for registering a vchiq driver
 * @__vchiq_driver: vchiq driver struct
 *
 * Helper macro for vchiq drivers which do not do anything special in
 * module init/exit. This eliminates a lot of boilerplate. Each module may only
 * use this macro once, and calling it replaces module_init() and module_exit()
 */
#define module_vchiq_driver(__vchiq_driver) \
	module_driver(__vchiq_driver, vchiq_driver_register, vchiq_driver_unregister)

#endif /* _VCHIQ_DEVICE_H */