drivers/net/can/kvaser_pciefd/kvaser_pciefd_devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/can/kvaser_pciefd/kvaser_pciefd_devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/kvaser_pciefd/kvaser_pciefd_devlink.c- Extension
.c- Size
- 1500 bytes
- Lines
- 61
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kvaser_pciefd.hlinux/netdevice.hnet/devlink.h
Detected Declarations
function Copyrightfunction kvaser_pciefd_devlink_port_registerfunction kvaser_pciefd_devlink_port_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
/* kvaser_pciefd devlink functions
*
* Copyright (C) 2025 KVASER AB, Sweden. All rights reserved.
*/
#include "kvaser_pciefd.h"
#include <linux/netdevice.h>
#include <net/devlink.h>
static int kvaser_pciefd_devlink_info_get(struct devlink *devlink,
struct devlink_info_req *req,
struct netlink_ext_ack *extack)
{
struct kvaser_pciefd *pcie = devlink_priv(devlink);
char buf[] = "xxx.xxx.xxxxx";
int ret;
if (pcie->fw_version.major) {
snprintf(buf, sizeof(buf), "%u.%u.%u",
pcie->fw_version.major,
pcie->fw_version.minor,
pcie->fw_version.build);
ret = devlink_info_version_running_put(req,
DEVLINK_INFO_VERSION_GENERIC_FW,
buf);
if (ret)
return ret;
}
return 0;
}
const struct devlink_ops kvaser_pciefd_devlink_ops = {
.info_get = kvaser_pciefd_devlink_info_get,
};
int kvaser_pciefd_devlink_port_register(struct kvaser_pciefd_can *can)
{
int ret;
struct devlink_port_attrs attrs = {
.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL,
.phys.port_number = can->can.dev->dev_port,
};
devlink_port_attrs_set(&can->devlink_port, &attrs);
ret = devlink_port_register(priv_to_devlink(can->kv_pcie),
&can->devlink_port, can->can.dev->dev_port);
if (ret)
return ret;
SET_NETDEV_DEVLINK_PORT(can->can.dev, &can->devlink_port);
return 0;
}
void kvaser_pciefd_devlink_port_unregister(struct kvaser_pciefd_can *can)
{
devlink_port_unregister(&can->devlink_port);
}
Annotation
- Immediate include surface: `kvaser_pciefd.h`, `linux/netdevice.h`, `net/devlink.h`.
- Detected declarations: `function Copyright`, `function kvaser_pciefd_devlink_port_register`, `function kvaser_pciefd_devlink_port_unregister`.
- Atlas domain: Driver Families / drivers/net.
- 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.