drivers/net/wwan/rpmsg_wwan_ctrl.c
Source file repositories/reference/linux-study-clean/drivers/net/wwan/rpmsg_wwan_ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wwan/rpmsg_wwan_ctrl.c- Extension
.c- Size
- 4353 bytes
- Lines
- 168
- 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.
- 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/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/rpmsg.hlinux/wwan.h
Detected Declarations
struct rpmsg_wwan_devfunction rpmsg_wwan_ctrl_callbackfunction rpmsg_wwan_ctrl_startfunction rpmsg_wwan_ctrl_stopfunction rpmsg_wwan_ctrl_txfunction rpmsg_wwan_ctrl_tx_blockingfunction rpmsg_wwan_ctrl_tx_pollfunction rpmsg_wwan_ctrl_probefunction rpmsg_wwan_ctrl_remove
Annotated Snippet
struct rpmsg_wwan_dev {
/* Lower level is a rpmsg dev, upper level is a wwan port */
struct rpmsg_device *rpdev;
struct wwan_port *wwan_port;
struct rpmsg_endpoint *ept;
};
static int rpmsg_wwan_ctrl_callback(struct rpmsg_device *rpdev,
void *buf, int len, void *priv, u32 src)
{
struct rpmsg_wwan_dev *rpwwan = priv;
struct sk_buff *skb;
skb = alloc_skb(len, GFP_ATOMIC);
if (!skb)
return -ENOMEM;
skb_put_data(skb, buf, len);
wwan_port_rx(rpwwan->wwan_port, skb);
return 0;
}
static int rpmsg_wwan_ctrl_start(struct wwan_port *port)
{
struct rpmsg_wwan_dev *rpwwan = wwan_port_get_drvdata(port);
struct rpmsg_channel_info chinfo = {
.src = rpwwan->rpdev->src,
.dst = RPMSG_ADDR_ANY,
};
strscpy(chinfo.name, rpwwan->rpdev->id.name, sizeof(chinfo.name));
rpwwan->ept = rpmsg_create_ept(rpwwan->rpdev, rpmsg_wwan_ctrl_callback,
rpwwan, chinfo);
if (!rpwwan->ept)
return -EREMOTEIO;
return 0;
}
static void rpmsg_wwan_ctrl_stop(struct wwan_port *port)
{
struct rpmsg_wwan_dev *rpwwan = wwan_port_get_drvdata(port);
rpmsg_destroy_ept(rpwwan->ept);
rpwwan->ept = NULL;
}
static int rpmsg_wwan_ctrl_tx(struct wwan_port *port, struct sk_buff *skb)
{
struct rpmsg_wwan_dev *rpwwan = wwan_port_get_drvdata(port);
int ret;
ret = rpmsg_trysend(rpwwan->ept, skb->data, skb->len);
if (ret)
return ret;
consume_skb(skb);
return 0;
}
static int rpmsg_wwan_ctrl_tx_blocking(struct wwan_port *port, struct sk_buff *skb)
{
struct rpmsg_wwan_dev *rpwwan = wwan_port_get_drvdata(port);
int ret;
ret = rpmsg_send(rpwwan->ept, skb->data, skb->len);
if (ret)
return ret;
consume_skb(skb);
return 0;
}
static __poll_t rpmsg_wwan_ctrl_tx_poll(struct wwan_port *port,
struct file *filp, poll_table *wait)
{
struct rpmsg_wwan_dev *rpwwan = wwan_port_get_drvdata(port);
return rpmsg_poll(rpwwan->ept, filp, wait);
}
static const struct wwan_port_ops rpmsg_wwan_pops = {
.start = rpmsg_wwan_ctrl_start,
.stop = rpmsg_wwan_ctrl_stop,
.tx = rpmsg_wwan_ctrl_tx,
.tx_blocking = rpmsg_wwan_ctrl_tx_blocking,
.tx_poll = rpmsg_wwan_ctrl_tx_poll,
};
static struct device *rpmsg_wwan_find_parent(struct device *dev)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/rpmsg.h`, `linux/wwan.h`.
- Detected declarations: `struct rpmsg_wwan_dev`, `function rpmsg_wwan_ctrl_callback`, `function rpmsg_wwan_ctrl_start`, `function rpmsg_wwan_ctrl_stop`, `function rpmsg_wwan_ctrl_tx`, `function rpmsg_wwan_ctrl_tx_blocking`, `function rpmsg_wwan_ctrl_tx_poll`, `function rpmsg_wwan_ctrl_probe`, `function rpmsg_wwan_ctrl_remove`.
- 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.