aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-24 18:28:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-24 18:28:02 -0400
commit7b5d4122d39f7c26ce42806b7a67cf04537545e6 (patch)
tree8cc8f2a8216e7d108fad62897a04c3f0cd00c0c7
parent3ce20a710f1dac8f5073d1b138039c75dd46d967 (diff)
Revert "misc: c2port: use dev_bin_attrs instead of hand-coding it"
This reverts commit 3ce20a710f1dac8f5073d1b138039c75dd46d967 It should go in through the driver-core tree, not the char-misc tree, my mistake. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/c2port/core.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index a3b8370c7dea..f32550a74bdd 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -867,17 +867,14 @@ static struct device_attribute c2port_attrs[] = {
867 __ATTR_NULL, 867 __ATTR_NULL,
868}; 868};
869 869
870static struct bin_attribute c2port_bin_attrs[] = { 870static struct bin_attribute c2port_bin_attrs = {
871 { 871 .attr = {
872 .attr = { 872 .name = "flash_data",
873 .name = "flash_data", 873 .mode = 0644
874 .mode = 0644
875 },
876 .read = c2port_read_flash_data,
877 .write = c2port_write_flash_data,
878 /* .size is computed at run-time */
879 }, 874 },
880 __ATTR_NULL 875 .read = c2port_read_flash_data,
876 .write = c2port_write_flash_data,
877 /* .size is computed at run-time */
881}; 878};
882 879
883/* 880/*
@@ -910,8 +907,6 @@ struct c2port_device *c2port_device_register(char *name,
910 goto error_idr_alloc; 907 goto error_idr_alloc;
911 c2dev->id = ret; 908 c2dev->id = ret;
912 909
913 c2port_bin_attrs[0].size = ops->blocks_num * ops->block_size;
914
915 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, 910 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
916 "c2port%d", c2dev->id); 911 "c2port%d", c2dev->id);
917 if (unlikely(IS_ERR(c2dev->dev))) { 912 if (unlikely(IS_ERR(c2dev->dev))) {
@@ -924,6 +919,12 @@ struct c2port_device *c2port_device_register(char *name,
924 c2dev->ops = ops; 919 c2dev->ops = ops;
925 mutex_init(&c2dev->mutex); 920 mutex_init(&c2dev->mutex);
926 921
922 /* Create binary file */
923 c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
924 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
925 if (unlikely(ret))
926 goto error_device_create_bin_file;
927
927 /* By default C2 port access is off */ 928 /* By default C2 port access is off */
928 c2dev->access = c2dev->flash_access = 0; 929 c2dev->access = c2dev->flash_access = 0;
929 ops->access(c2dev, 0); 930 ops->access(c2dev, 0);
@@ -936,6 +937,9 @@ struct c2port_device *c2port_device_register(char *name,
936 937
937 return c2dev; 938 return c2dev;
938 939
940error_device_create_bin_file:
941 device_destroy(c2port_class, 0);
942
939error_device_create: 943error_device_create:
940 spin_lock_irq(&c2port_idr_lock); 944 spin_lock_irq(&c2port_idr_lock);
941 idr_remove(&c2port_idr, c2dev->id); 945 idr_remove(&c2port_idr, c2dev->id);
@@ -955,6 +959,7 @@ void c2port_device_unregister(struct c2port_device *c2dev)
955 959
956 dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); 960 dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name);
957 961
962 device_remove_bin_file(c2dev->dev, &c2port_bin_attrs);
958 spin_lock_irq(&c2port_idr_lock); 963 spin_lock_irq(&c2port_idr_lock);
959 idr_remove(&c2port_idr, c2dev->id); 964 idr_remove(&c2port_idr, c2dev->id);
960 spin_unlock_irq(&c2port_idr_lock); 965 spin_unlock_irq(&c2port_idr_lock);
@@ -980,7 +985,6 @@ static int __init c2port_init(void)
980 return PTR_ERR(c2port_class); 985 return PTR_ERR(c2port_class);
981 } 986 }
982 c2port_class->dev_attrs = c2port_attrs; 987 c2port_class->dev_attrs = c2port_attrs;
983 c2port_class->dev_bin_attrs = c2port_bin_attrs;
984 988
985 return 0; 989 return 0;
986} 990}