include/media/media-request.h
Source file repositories/reference/linux-study-clean/include/media/media-request.h
File Facts
- System
- Linux kernel
- Corpus path
include/media/media-request.h- Extension
.h- Size
- 13581 bytes
- Lines
- 481
- Domain
- Repository Root And Misc
- Bucket
- include
- Inferred role
- Repository Root And Misc: implementation source
- Status
- source implementation candidate
Why This File Exists
Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- 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/list.hlinux/slab.hlinux/spinlock.hlinux/refcount.hmedia/media-device.h
Detected Declarations
struct media_request_objectstruct media_requeststruct media_request_object_opsstruct media_request_objectenum media_request_statefunction media_request_lock_for_accessfunction media_request_unlock_for_accessfunction media_request_lock_for_updatefunction media_request_unlock_for_updatefunction media_request_getfunction media_request_manual_completefunction media_request_getfunction media_request_object_getfunction media_request_lock_for_accessfunction media_request_unlock_for_accessfunction media_request_unlock_for_updatefunction media_request_object_initfunction media_request_object_bindfunction media_request_object_unbind
Annotated Snippet
struct media_request {
struct media_device *mdev;
struct kref kref;
char debug_str[TASK_COMM_LEN + 11];
enum media_request_state state;
unsigned int updating_count;
unsigned int access_count;
struct list_head objects;
unsigned int num_incomplete_objects;
bool manual_completion;
wait_queue_head_t poll_wait;
spinlock_t lock;
};
#ifdef CONFIG_MEDIA_CONTROLLER
/**
* media_request_lock_for_access - Lock the request to access its objects
*
* @req: The media request
*
* Use before accessing a completed request. A reference to the request must
* be held during the access. This usually takes place automatically through
* a file handle. Use @media_request_unlock_for_access when done.
*/
static inline int __must_check
media_request_lock_for_access(struct media_request *req)
{
unsigned long flags;
int ret = -EBUSY;
spin_lock_irqsave(&req->lock, flags);
if (req->state == MEDIA_REQUEST_STATE_COMPLETE) {
req->access_count++;
ret = 0;
}
spin_unlock_irqrestore(&req->lock, flags);
return ret;
}
/**
* media_request_unlock_for_access - Unlock a request previously locked for
* access
*
* @req: The media request
*
* Unlock a request that has previously been locked using
* @media_request_lock_for_access.
*/
static inline void media_request_unlock_for_access(struct media_request *req)
{
unsigned long flags;
spin_lock_irqsave(&req->lock, flags);
if (!WARN_ON(!req->access_count))
req->access_count--;
spin_unlock_irqrestore(&req->lock, flags);
}
/**
* media_request_lock_for_update - Lock the request for updating its objects
*
* @req: The media request
*
* Use before updating a request, i.e. adding, modifying or removing a request
* object in it. A reference to the request must be held during the update. This
* usually takes place automatically through a file handle. Use
* @media_request_unlock_for_update when done.
*/
static inline int __must_check
media_request_lock_for_update(struct media_request *req)
{
unsigned long flags;
int ret = 0;
spin_lock_irqsave(&req->lock, flags);
if (req->state == MEDIA_REQUEST_STATE_IDLE ||
req->state == MEDIA_REQUEST_STATE_UPDATING) {
req->state = MEDIA_REQUEST_STATE_UPDATING;
req->updating_count++;
} else {
ret = -EBUSY;
}
spin_unlock_irqrestore(&req->lock, flags);
return ret;
}
/**
Annotation
- Immediate include surface: `linux/list.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/refcount.h`, `media/media-device.h`.
- Detected declarations: `struct media_request_object`, `struct media_request`, `struct media_request_object_ops`, `struct media_request_object`, `enum media_request_state`, `function media_request_lock_for_access`, `function media_request_unlock_for_access`, `function media_request_lock_for_update`, `function media_request_unlock_for_update`, `function media_request_get`.
- Atlas domain: Repository Root And Misc / include.
- Implementation status: source 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.