drivers/i3c/device.c
Source file repositories/reference/linux-study-clean/drivers/i3c/device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i3c/device.c- Extension
.c- Size
- 8746 bytes
- Lines
- 352
- Domain
- Driver Families
- Bucket
- drivers/i3c
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/bug.hlinux/completion.hlinux/device.hlinux/mutex.hlinux/slab.hinternals.h
Detected Declarations
function Copyrightfunction i3c_device_do_setdasafunction i3c_device_get_infofunction i3c_device_disable_ibifunction i3c_device_enable_ibifunction i3c_device_request_ibifunction i3c_device_free_ibifunction i3cdev_to_devfunction i3c_device_match_idfunction i3c_device_get_supported_xfer_modefunction i3c_driver_register_with_ownerfunction i3c_driver_unregisterexport i3c_device_do_xfersexport i3c_device_do_setdasaexport i3c_device_get_infoexport i3c_device_disable_ibiexport i3c_device_enable_ibiexport i3c_device_request_ibiexport i3c_device_free_ibiexport i3cdev_to_devexport i3c_device_match_idexport i3c_device_get_supported_xfer_modeexport i3c_driver_register_with_ownerexport i3c_driver_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2018 Cadence Design Systems Inc.
*
* Author: Boris Brezillon <boris.brezillon@bootlin.com>
*/
#include <linux/atomic.h>
#include <linux/bug.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include "internals.h"
/**
* i3c_device_do_xfers() - do I3C transfers directed to a specific device
*
* @dev: device with which the transfers should be done
* @xfers: array of transfers
* @nxfers: number of transfers
* @mode: transfer mode
*
* Initiate one or several private SDR transfers with @dev.
*
* This function can sleep and thus cannot be called in atomic context.
*
* Return:
* * 0 in case of success, a negative error core otherwise.
* * -EAGAIN: controller lost address arbitration. Target (IBI, HJ or
* controller role request) win the bus. Client driver needs to resend the
* 'xfers' some time later. See I3C spec ver 1.1.1 09-Jun-2021. Section:
* 5.1.2.2.3.
*/
int i3c_device_do_xfers(struct i3c_device *dev, struct i3c_xfer *xfers,
int nxfers, enum i3c_xfer_mode mode)
{
int ret, i;
if (nxfers < 1)
return 0;
for (i = 0; i < nxfers; i++) {
if (!xfers[i].len || !xfers[i].data.in)
return -EINVAL;
}
ret = i3c_bus_rpm_get(dev->bus);
if (ret)
return ret;
i3c_bus_normaluse_lock(dev->bus);
ret = i3c_dev_do_xfers_locked(dev->desc, xfers, nxfers, mode);
i3c_bus_normaluse_unlock(dev->bus);
i3c_bus_rpm_put(dev->bus);
return ret;
}
EXPORT_SYMBOL_GPL(i3c_device_do_xfers);
/**
* i3c_device_do_setdasa() - do I3C dynamic address assignement with
* static address
*
* @dev: device with which the DAA should be done
*
* Return: 0 in case of success, a negative error core otherwise.
*/
int i3c_device_do_setdasa(struct i3c_device *dev)
{
int ret;
ret = i3c_bus_rpm_get(dev->bus);
if (ret)
return ret;
i3c_bus_normaluse_lock(dev->bus);
ret = i3c_dev_setdasa_locked(dev->desc);
i3c_bus_normaluse_unlock(dev->bus);
i3c_bus_rpm_put(dev->bus);
return ret;
}
EXPORT_SYMBOL_GPL(i3c_device_do_setdasa);
/**
* i3c_device_get_info() - get I3C device information
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bug.h`, `linux/completion.h`, `linux/device.h`, `linux/mutex.h`, `linux/slab.h`, `internals.h`.
- Detected declarations: `function Copyright`, `function i3c_device_do_setdasa`, `function i3c_device_get_info`, `function i3c_device_disable_ibi`, `function i3c_device_enable_ibi`, `function i3c_device_request_ibi`, `function i3c_device_free_ibi`, `function i3cdev_to_dev`, `function i3c_device_match_id`, `function i3c_device_get_supported_xfer_mode`.
- Atlas domain: Driver Families / drivers/i3c.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.