# device.c File Reference

`#include <sys/device.h>`
`#include <ubixos/spinlock.h>`
`#include <lib/kmalloc.h>`
`#include <lib/kprintf.h>`
`#include <assert.h>`

Include dependency graph for device.c:

Go to the source code of this file.

## Functions

int | device_add (int minor, char type, struct device_interface *devInfo)
device_node * | device_find (int major, int minor)
int | device_remove (struct device_node *deviceToDelete)

## Variables

static struct device_node * | devices = 0x0
static spinLock_t | deviceSpinLock = SPIN_LOCK_INITIALIZER

## Function Documentation

int device_add | ( | int | minor,
|  | char | type,
|  | struct device_interface * | devInfo |
| ) |  |  |

Definition at line 51 of file device.c.

References devices, deviceSpinLock, device_node::devInfo, device_interface::init, device_interface::initialized, kmalloc(), kprintf(), device_node::minor, device_node::next, NULL, device_node::prev, spinLock(), spinUnlock(), and device_node::type.

Referenced by fdc_init(), and initHardDisk().

Here is the call graph for this function:

struct device_node* device_find | ( | int | major,
|  | int | minor |
| ) |  |  |

Definition at line 86 of file device.c.

References devices, deviceSpinLock, device_node::devInfo, device_interface::major, device_node::minor, device_node::next, spinLock(), and spinUnlock().

Referenced by devfs_open(), devfs_read(), devfs_write(), and vfs_mount().

Here is the call graph for this function:

int device_remove | ( | struct device_node * | deviceToDelete | ) |

Definition at line 110 of file device.c.

References devices, deviceSpinLock, kfree(), device_node::next, NULL, spinLock(), and spinUnlock().

Here is the call graph for this function:

## Variable Documentation

struct device_node* devices = 0x0`[static]`

Definition at line 37 of file device.c.

Referenced by device_add(), device_find(), and device_remove().

spinLock_t deviceSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 38 of file device.c.

Referenced by device_add(), device_find(), and device_remove().