arch/mips/sgi-ip22/ip22-gio.c

Source file repositories/reference/linux-study-clean/arch/mips/sgi-ip22/ip22-gio.c

File Facts

System
Linux kernel
Corpus path
arch/mips/sgi-ip22/ip22-gio.c
Extension
.c
Size
9561 bytes
Lines
421
Domain
Architecture Layer
Bucket
arch/mips
Inferred role
Architecture Layer: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct bus_type gio_bus_type;

static struct {
	const char *name;
	__u8	   id;
} gio_name_table[] = {
	{ .name = "SGI Impact", .id = 0x10 },
	{ .name = "Phobos G160", .id = 0x35 },
	{ .name = "Phobos G130", .id = 0x36 },
	{ .name = "Phobos G100", .id = 0x37 },
	{ .name = "Set Engineering GFE", .id = 0x38 },
	/* fake IDs */
	{ .name = "SGI Newport", .id = 0x7e },
	{ .name = "SGI GR2/GR3", .id = 0x7f },
};

static struct device *gio_bus;

/**
 * gio_match_device - Tell if an of_device structure has a matching
 * gio_match structure
 * @ids: array of of device match structures to search in
 * @dev: the of device structure to match against
 *
 * Used by a driver to check whether an of_device present in the
 * system is in its list of supported devices.
 */
static const struct gio_device_id *
gio_match_device(const struct gio_device_id *match,
		 const struct gio_device *dev)
{
	const struct gio_device_id *ids;

	for (ids = match; ids->id != 0xff; ids++)
		if (ids->id == dev->id.id)
			return ids;

	return NULL;
}

struct gio_device *gio_dev_get(struct gio_device *dev)
{
	struct device *tmp;

	if (!dev)
		return NULL;
	tmp = get_device(&dev->dev);
	if (tmp)
		return to_gio_device(tmp);
	else
		return NULL;
}
EXPORT_SYMBOL_GPL(gio_dev_get);

void gio_dev_put(struct gio_device *dev)
{
	if (dev)
		put_device(&dev->dev);
}
EXPORT_SYMBOL_GPL(gio_dev_put);

/**
 * gio_release_dev - free an gio device structure when all users of it are finished.
 * @dev: device that's been disconnected
 *
 * Will be called only by the device core when all users of this gio device are
 * done.
 */
static void gio_release_dev(struct device *dev)
{
	struct gio_device *giodev;

	giodev = to_gio_device(dev);
	kfree(giodev);
}

int gio_device_register(struct gio_device *giodev)
{
	giodev->dev.bus = &gio_bus_type;
	giodev->dev.parent = gio_bus;
	giodev->dev.release = gio_release_dev;

	return device_register(&giodev->dev);
}
EXPORT_SYMBOL_GPL(gio_device_register);

void gio_device_unregister(struct gio_device *giodev)
{
	device_unregister(&giodev->dev);
}

Annotation

Implementation Notes