drivers/mfd/viperboard.c
Source file repositories/reference/linux-study-clean/drivers/mfd/viperboard.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/viperboard.c- Extension
.c- Size
- 3055 bytes
- Lines
- 128
- Domain
- Driver Families
- Bucket
- drivers/mfd
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/module.hlinux/slab.hlinux/types.hlinux/mutex.hlinux/mfd/core.hlinux/mfd/viperboard.hlinux/usb.h
Detected Declarations
function vprbrd_probefunction vprbrd_disconnect
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Nano River Technologies viperboard driver
*
* This is the core driver for the viperboard. There are cell drivers
* available for I2C, ADC and both GPIOs. SPI is not yet supported.
* The drivers do not support all features the board exposes. See user
* manual of the viperboard.
*
* (C) 2012 by Lemonage GmbH
* Author: Lars Poeschel <poeschel@lemonage.de>
* All rights reserved.
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/mfd/core.h>
#include <linux/mfd/viperboard.h>
#include <linux/usb.h>
static const struct usb_device_id vprbrd_table[] = {
{ USB_DEVICE(0x2058, 0x1005) }, /* Nano River Technologies */
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, vprbrd_table);
static const struct mfd_cell vprbrd_devs[] = {
{
.name = "viperboard-gpio",
},
{
.name = "viperboard-i2c",
},
{
.name = "viperboard-adc",
},
};
static int vprbrd_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
struct vprbrd *vb;
u16 version = 0;
int pipe, ret;
/* allocate memory for our device state and initialize it */
vb = kzalloc_obj(*vb);
if (!vb)
return -ENOMEM;
mutex_init(&vb->lock);
vb->usb_dev = interface_to_usbdev(interface);
/* save our data pointer in this interface device */
usb_set_intfdata(interface, vb);
dev_set_drvdata(&vb->pdev.dev, vb);
/* get version information, major first, minor then */
pipe = usb_rcvctrlpipe(vb->usb_dev, 0);
ret = usb_control_msg(vb->usb_dev, pipe, VPRBRD_USB_REQUEST_MAJOR,
VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, vb->buf, 1,
VPRBRD_USB_TIMEOUT_MS);
if (ret == 1)
version = vb->buf[0];
ret = usb_control_msg(vb->usb_dev, pipe, VPRBRD_USB_REQUEST_MINOR,
VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, vb->buf, 1,
VPRBRD_USB_TIMEOUT_MS);
if (ret == 1) {
version <<= 8;
version = version | vb->buf[0];
}
dev_info(&interface->dev,
"version %x.%02x found at bus %03d address %03d\n",
version >> 8, version & 0xff,
vb->usb_dev->bus->busnum, vb->usb_dev->devnum);
ret = mfd_add_hotplug_devices(&interface->dev, vprbrd_devs,
ARRAY_SIZE(vprbrd_devs));
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/module.h`, `linux/slab.h`, `linux/types.h`, `linux/mutex.h`, `linux/mfd/core.h`, `linux/mfd/viperboard.h`.
- Detected declarations: `function vprbrd_probe`, `function vprbrd_disconnect`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.