sysfs_slave.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) | sysfs_slave.c (565e3afaefee3cfe13783c2b1e8d5ceb09023beb) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2// Copyright(c) 2015-2020 Intel Corporation. 3 4#include <linux/device.h> 5#include <linux/mod_devicetable.h> 6#include <linux/slab.h> 7#include <linux/sysfs.h> 8#include <linux/soundwire/sdw.h> 9#include <linux/soundwire/sdw_type.h> 10#include "bus.h" 11#include "sysfs_local.h" 12 13/* 14 * Slave sysfs 15 */ 16 17/* 18 * The sysfs for Slave reflects the MIPI description as given | 1// SPDX-License-Identifier: GPL-2.0-only 2// Copyright(c) 2015-2020 Intel Corporation. 3 4#include <linux/device.h> 5#include <linux/mod_devicetable.h> 6#include <linux/slab.h> 7#include <linux/sysfs.h> 8#include <linux/soundwire/sdw.h> 9#include <linux/soundwire/sdw_type.h> 10#include "bus.h" 11#include "sysfs_local.h" 12 13/* 14 * Slave sysfs 15 */ 16 17/* 18 * The sysfs for Slave reflects the MIPI description as given |
19 * in the MIPI DisCo spec | 19 * in the MIPI DisCo spec. 20 * status and device_number come directly from the MIPI SoundWire 21 * 1.x specification. |
20 * 21 * Base file is device | 22 * 23 * Base file is device |
24 * |---- status 25 * |---- device_number |
|
22 * |---- modalias 23 * |---- dev-properties 24 * |---- mipi_revision 25 * |---- wake_capable 26 * |---- test_mode_capable 27 * |---- clk_stop_mode1 28 * |---- simple_clk_stop_capable 29 * |---- clk_stop_timeout --- 91 unchanged lines hidden (view full) --- 121 &dev_attr_sink_ports.attr, 122 NULL, 123}; 124 125/* 126 * we don't use ATTRIBUTES_GROUP here since we want to add a subdirectory 127 * for device-level properties 128 */ | 26 * |---- modalias 27 * |---- dev-properties 28 * |---- mipi_revision 29 * |---- wake_capable 30 * |---- test_mode_capable 31 * |---- clk_stop_mode1 32 * |---- simple_clk_stop_capable 33 * |---- clk_stop_timeout --- 91 unchanged lines hidden (view full) --- 125 &dev_attr_sink_ports.attr, 126 NULL, 127}; 128 129/* 130 * we don't use ATTRIBUTES_GROUP here since we want to add a subdirectory 131 * for device-level properties 132 */ |
129static struct attribute_group sdw_slave_dev_attr_group = { | 133static const struct attribute_group sdw_slave_dev_attr_group = { |
130 .attrs = slave_dev_attrs, 131 .name = "dev-properties", 132}; 133 134/* 135 * DP0 sysfs 136 */ 137 --- 69 unchanged lines hidden (view full) --- 207 if (slave->prop.source_ports || slave->prop.sink_ports) { 208 ret = sdw_slave_sysfs_dpn_init(slave); 209 if (ret < 0) 210 return ret; 211 } 212 213 return 0; 214} | 134 .attrs = slave_dev_attrs, 135 .name = "dev-properties", 136}; 137 138/* 139 * DP0 sysfs 140 */ 141 --- 69 unchanged lines hidden (view full) --- 211 if (slave->prop.source_ports || slave->prop.sink_ports) { 212 ret = sdw_slave_sysfs_dpn_init(slave); 213 if (ret < 0) 214 return ret; 215 } 216 217 return 0; 218} |
219 220/* 221 * the status is shown in capital letters for UNATTACHED and RESERVED 222 * on purpose, to highligh users to the fact that these status values 223 * are not expected. 224 */ 225static const char *const slave_status[] = { 226 [SDW_SLAVE_UNATTACHED] = "UNATTACHED", 227 [SDW_SLAVE_ATTACHED] = "Attached", 228 [SDW_SLAVE_ALERT] = "Alert", 229 [SDW_SLAVE_RESERVED] = "RESERVED", 230}; 231 232static ssize_t status_show(struct device *dev, 233 struct device_attribute *attr, char *buf) 234{ 235 struct sdw_slave *slave = dev_to_sdw_dev(dev); 236 237 return sprintf(buf, "%s\n", slave_status[slave->status]); 238} 239static DEVICE_ATTR_RO(status); 240 241static ssize_t device_number_show(struct device *dev, 242 struct device_attribute *attr, char *buf) 243{ 244 struct sdw_slave *slave = dev_to_sdw_dev(dev); 245 246 if (slave->status == SDW_SLAVE_UNATTACHED) 247 return sprintf(buf, "%s", "N/A"); 248 else 249 return sprintf(buf, "%d", slave->dev_num); 250} 251static DEVICE_ATTR_RO(device_number); 252 253static struct attribute *slave_status_attrs[] = { 254 &dev_attr_status.attr, 255 &dev_attr_device_number.attr, 256 NULL, 257}; 258 259/* 260 * we don't use ATTRIBUTES_GROUP here since the group is used in a 261 * separate file and can't be handled as a static. 262 */ 263static const struct attribute_group sdw_slave_status_attr_group = { 264 .attrs = slave_status_attrs, 265}; 266 267const struct attribute_group *sdw_slave_status_attr_groups[] = { 268 &sdw_slave_status_attr_group, 269 NULL 270}; |
|