Commit 1ebfdbcd authored by Andrey Filippov's avatar Andrey Filippov

split control/global registers to separate directories in sysfs

parent 0220703b
Index: git/drivers/misc/Kconfig Index: git/drivers/misc/Kconfig
=================================================================== ===================================================================
--- git.orig/drivers/misc/Kconfig 2013-11-26 00:53:11.204122076 -0700 --- git.orig/drivers/misc/Kconfig 2013-11-26 01:01:48.820127445 -0700
+++ git/drivers/misc/Kconfig 2013-11-26 00:53:14.044122105 -0700 +++ git/drivers/misc/Kconfig 2013-11-26 01:01:51.944127477 -0700
@@ -549,6 +549,13 @@ @@ -549,6 +549,13 @@
their requirements. their requirements.
...@@ -18,8 +18,8 @@ Index: git/drivers/misc/Kconfig ...@@ -18,8 +18,8 @@ Index: git/drivers/misc/Kconfig
source "drivers/misc/eeprom/Kconfig" source "drivers/misc/eeprom/Kconfig"
Index: git/drivers/misc/Makefile Index: git/drivers/misc/Makefile
=================================================================== ===================================================================
--- git.orig/drivers/misc/Makefile 2013-11-26 00:53:11.204122076 -0700 --- git.orig/drivers/misc/Makefile 2013-11-26 01:01:48.820127445 -0700
+++ git/drivers/misc/Makefile 2013-11-26 00:53:14.044122105 -0700 +++ git/drivers/misc/Makefile 2013-11-26 01:01:51.944127477 -0700
@@ -55,3 +55,4 @@ @@ -55,3 +55,4 @@
obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o
obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM) += sram.o
...@@ -28,8 +28,8 @@ Index: git/drivers/misc/Makefile ...@@ -28,8 +28,8 @@ Index: git/drivers/misc/Makefile
Index: git/drivers/misc/vsc330x.c Index: git/drivers/misc/vsc330x.c
=================================================================== ===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ git/drivers/misc/vsc330x.c 2013-11-26 00:58:21.924125299 -0700 +++ git/drivers/misc/vsc330x.c 2013-11-26 09:41:58.660451163 -0700
@@ -0,0 +1,791 @@ @@ -0,0 +1,805 @@
+/*!*************************************************************************** +/*!***************************************************************************
+ *! FILE NAME : vsc330x.c + *! FILE NAME : vsc330x.c
+ *! DESCRIPTION: control of the VSC3304 4x4 crosspoint switch + *! DESCRIPTION: control of the VSC3304 4x4 crosspoint switch
...@@ -267,17 +267,21 @@ Index: git/drivers/misc/vsc330x.c ...@@ -267,17 +267,21 @@ Index: git/drivers/misc/vsc330x.c
+static ssize_t address_range_show (struct device *dev, struct device_attribute *attr, char *buf); +static ssize_t address_range_show (struct device *dev, struct device_attribute *attr, char *buf);
+static ssize_t address_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); +static ssize_t address_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
+ +
+static DEVICE_ATTR(connection, SYSFS_PERMISSIONS, global_connection_show, global_connection_store); +/* Global registers - writes applied to all port registers. No sense to read (so write only), but functions preserved
+static DEVICE_ATTR(ISE, SYSFS_PERMISSIONS, global_ISE_show, global_ISE_store); + * Placed in "globals" directory */
+static DEVICE_ATTR(input_state, SYSFS_PERMISSIONS, global_input_state_show, global_input_state_store); +static DEVICE_ATTR(connection, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_connection_show, global_connection_store);
+static DEVICE_ATTR(input_LOS, SYSFS_PERMISSIONS, global_input_LOS_show, global_input_LOS_store); +static DEVICE_ATTR(ISE, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_ISE_show, global_ISE_store);
+static DEVICE_ATTR(output_PRE_long, SYSFS_PERMISSIONS, global_output_PRE_long_show, global_output_PRE_long_store); +static DEVICE_ATTR(input_state, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_input_state_show, global_input_state_store);
+static DEVICE_ATTR(output_PRE_short, SYSFS_PERMISSIONS, global_output_PRE_short_show, global_output_PRE_short_store); +static DEVICE_ATTR(input_LOS, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_input_LOS_show, global_input_LOS_store);
+static DEVICE_ATTR(output_level, SYSFS_PERMISSIONS, global_output_level_show, global_output_level_store); +static DEVICE_ATTR(output_PRE_long, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_output_PRE_long_show, global_output_PRE_long_store);
+static DEVICE_ATTR(output_state, SYSFS_PERMISSIONS, global_output_state_show, global_output_state_store); +static DEVICE_ATTR(output_PRE_short, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_output_PRE_short_show, global_output_PRE_short_store);
+static DEVICE_ATTR(status_0, SYSFS_PERMISSIONS, global_status_0_show, global_status_0_store); +static DEVICE_ATTR(output_level, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_output_level_show, global_output_level_store);
+static DEVICE_ATTR(status_1, SYSFS_PERMISSIONS, global_status_1_show, global_status_1_store); +static DEVICE_ATTR(output_state, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_output_state_show, global_output_state_store);
+static DEVICE_ATTR(core_config_word, SYSFS_PERMISSIONS, core_config_word_show, core_config_word_store); +static DEVICE_ATTR(status_0_on_LOS, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_status_0_show, global_status_0_store);
+static DEVICE_ATTR(status_1_on_LOS, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, global_status_1_show, global_status_1_store);
+
+/* control/status registers , placed in "control" directory */
+static DEVICE_ATTR(core_word, SYSFS_PERMISSIONS, core_config_word_show, core_config_word_store);
+static DEVICE_ATTR(core_left_bias_en, SYSFS_PERMISSIONS, core_left_bias_en_show, core_left_bias_en_store); +static DEVICE_ATTR(core_left_bias_en, SYSFS_PERMISSIONS, core_left_bias_en_show, core_left_bias_en_store);
+static DEVICE_ATTR(core_right_bias_en,SYSFS_PERMISSIONS, core_right_bias_en_show, core_right_bias_en_store); +static DEVICE_ATTR(core_right_bias_en,SYSFS_PERMISSIONS, core_right_bias_en_show, core_right_bias_en_store);
+static DEVICE_ATTR(core_buffer_on, SYSFS_PERMISSIONS, core_buffer_on_show, core_buffer_on_store); +static DEVICE_ATTR(core_buffer_on, SYSFS_PERMISSIONS, core_buffer_on_show, core_buffer_on_store);
...@@ -295,9 +299,18 @@ Index: git/drivers/misc/vsc330x.c ...@@ -295,9 +299,18 @@ Index: git/drivers/misc/vsc330x.c
+ &dev_attr_output_PRE_short.attr, + &dev_attr_output_PRE_short.attr,
+ &dev_attr_output_level.attr, + &dev_attr_output_level.attr,
+ &dev_attr_output_state.attr, + &dev_attr_output_state.attr,
+ &dev_attr_status_0.attr, + &dev_attr_status_0_on_LOS.attr,
+ &dev_attr_status_1.attr, + &dev_attr_status_1_on_LOS.attr,
+ &dev_attr_core_config_word.attr, + NULL
+};
+
+static const struct attribute_group dev_attr_globals_group = {
+ .attrs = globals_dev_attrs,
+ .name = "globals",
+};
+
+static struct attribute *control_dev_attrs[] = {
+ &dev_attr_core_word.attr,
+ &dev_attr_core_left_bias_en.attr, + &dev_attr_core_left_bias_en.attr,
+ &dev_attr_core_right_bias_en.attr, + &dev_attr_core_right_bias_en.attr,
+ &dev_attr_core_buffer_on.attr, + &dev_attr_core_buffer_on.attr,
...@@ -308,9 +321,9 @@ Index: git/drivers/misc/vsc330x.c ...@@ -308,9 +321,9 @@ Index: git/drivers/misc/vsc330x.c
+ NULL + NULL
+}; +};
+ +
+static const struct attribute_group dev_attr_globals_group = { +static const struct attribute_group dev_attr_control_group = {
+ .attrs = globals_dev_attrs, + .attrs = control_dev_attrs,
+ .name = "globals", + .name = "control",
+}; +};
+ +
+ +
...@@ -373,6 +386,7 @@ Index: git/drivers/misc/vsc330x.c ...@@ -373,6 +386,7 @@ Index: git/drivers/misc/vsc330x.c
+ struct vsc330x_data_t *clientdata = i2c_get_clientdata(client); + struct vsc330x_data_t *clientdata = i2c_get_clientdata(client);
+ int ports=clientdata->out_ports; + int ports=clientdata->out_ports;
+ int retval=0; + int retval=0;
+ if (&dev->kobj) {
+ if ((retval=make_group (dev, "connections", ports, SYSFS_PERMISSIONS, connection_show, connection_store))) return retval; + if ((retval=make_group (dev, "connections", ports, SYSFS_PERMISSIONS, connection_show, connection_store))) return retval;
+ if ((retval=make_group (dev, "input_ISE_short", ports, SYSFS_PERMISSIONS, input_ISE_short_show, input_ISE_short_store))) return retval; + if ((retval=make_group (dev, "input_ISE_short", ports, SYSFS_PERMISSIONS, input_ISE_short_show, input_ISE_short_store))) return retval;
+ if ((retval=make_group (dev, "input_ISE_medium", ports, SYSFS_PERMISSIONS, input_ISE_medium_show, input_ISE_medium_store))) return retval; + if ((retval=make_group (dev, "input_ISE_medium", ports, SYSFS_PERMISSIONS, input_ISE_medium_show, input_ISE_medium_store))) return retval;
...@@ -391,8 +405,8 @@ Index: git/drivers/misc/vsc330x.c ...@@ -391,8 +405,8 @@ Index: git/drivers/misc/vsc330x.c
+ if ((retval=make_group (dev, "forward_OOB", ports, SYSFS_PERMISSIONS, forward_OOB_show, forward_OOB_store))) return retval; + if ((retval=make_group (dev, "forward_OOB", ports, SYSFS_PERMISSIONS, forward_OOB_show, forward_OOB_store))) return retval;
+ if ((retval=make_group (dev, "status_0_on_LOS", ports, SYSFS_PERMISSIONS, status_0_on_LOS_show, status_0_on_LOS_store))) return retval; + if ((retval=make_group (dev, "status_0_on_LOS", ports, SYSFS_PERMISSIONS, status_0_on_LOS_show, status_0_on_LOS_store))) return retval;
+ if ((retval=make_group (dev, "status_1_on_LOS", ports, SYSFS_PERMISSIONS, status_1_on_LOS_show, status_1_on_LOS_store))) return retval; + if ((retval=make_group (dev, "status_1_on_LOS", ports, SYSFS_PERMISSIONS, status_1_on_LOS_show, status_1_on_LOS_store))) return retval;
+ if (&dev->kobj) { + if ((retval = sysfs_create_group(&dev->kobj, &dev_attr_globals_group))) return retval;
+ retval = sysfs_create_group(&dev->kobj, &dev_attr_globals_group); + if ((retval = sysfs_create_group(&dev->kobj, &dev_attr_control_group))) return retval;
+ } + }
+ return retval; + return retval;
+} +}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment