drivers/soundwire/sysfs_slave.c

Source file repositories/reference/linux-study-clean/drivers/soundwire/sysfs_slave.c

File Facts

System
Linux kernel
Corpus path
drivers/soundwire/sysfs_slave.c
Extension
.c
Size
6744 bytes
Lines
267
Domain
Driver Families
Bucket
drivers/soundwire
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
// Copyright(c) 2015-2020 Intel Corporation.

#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include "bus.h"
#include "sysfs_local.h"

/*
 * Slave sysfs
 */

/*
 * The sysfs for Slave reflects the MIPI description as given
 * in the MIPI DisCo spec.
 * status and device_number come directly from the MIPI SoundWire
 * 1.x specification.
 *
 * Base file is device
 *	|---- status
 *	|---- device_number
 *	|---- modalias
 *	|---- dev-properties
 *		|---- mipi_revision
 *		|---- wake_capable
 *		|---- test_mode_capable
 *		|---- clk_stop_mode1
 *		|---- simple_clk_stop_capable
 *		|---- clk_stop_timeout
 *		|---- ch_prep_timeout
 *		|---- reset_behave
 *		|---- high_PHY_capable
 *		|---- paging_support
 *		|---- bank_delay_support
 *		|---- p15_behave
 *		|---- master_count
 *		|---- source_ports
 *		|---- sink_ports
 *	|---- dp0
 *		|---- max_word
 *		|---- min_word
 *		|---- words
 *		|---- BRA_flow_controlled
 *		|---- simple_ch_prep_sm
 *		|---- imp_def_interrupts
 *	|---- dpN_<sink/src>
 *		|---- max_word
 *		|---- min_word
 *		|---- words
 *		|---- type
 *		|---- max_grouping
 *		|---- simple_ch_prep_sm
 *		|---- ch_prep_timeout
 *		|---- imp_def_interrupts
 *		|---- min_ch
 *		|---- max_ch
 *		|---- channels
 *		|---- ch_combinations
 *		|---- max_async_buffer
 *		|---- block_pack_mode
 *		|---- port_encoding
 *
 */

#define sdw_slave_attr(field, format_string)			\
static ssize_t field##_show(struct device *dev,			\
			    struct device_attribute *attr,	\
			    char *buf)				\
{								\
	struct sdw_slave *slave = dev_to_sdw_dev(dev);		\
	return sprintf(buf, format_string, slave->prop.field);	\
}								\
static DEVICE_ATTR_RO(field)

sdw_slave_attr(mipi_revision, "0x%x\n");
sdw_slave_attr(wake_capable, "%d\n");
sdw_slave_attr(test_mode_capable, "%d\n");
sdw_slave_attr(clk_stop_mode1, "%d\n");
sdw_slave_attr(simple_clk_stop_capable, "%d\n");
sdw_slave_attr(clk_stop_timeout, "%d\n");
sdw_slave_attr(ch_prep_timeout, "%d\n");
sdw_slave_attr(reset_behave, "%d\n");
sdw_slave_attr(high_PHY_capable, "%d\n");
sdw_slave_attr(paging_support, "%d\n");
sdw_slave_attr(bank_delay_support, "%d\n");
sdw_slave_attr(p15_behave, "%d\n");

Annotation

Implementation Notes