diff options
-rw-r--r-- | drivers/misc/c2port/core.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index f32550a74bdd..a3b8370c7dea 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c | |||
@@ -867,14 +867,17 @@ static struct device_attribute c2port_attrs[] = { | |||
867 | __ATTR_NULL, | 867 | __ATTR_NULL, |
868 | }; | 868 | }; |
869 | 869 | ||
870 | static struct bin_attribute c2port_bin_attrs = { | 870 | static struct bin_attribute c2port_bin_attrs[] = { |
871 | .attr = { | 871 | { |
872 | .name = "flash_data", | 872 | .attr = { |
873 | .mode = 0644 | 873 | .name = "flash_data", |
874 | .mode = 0644 | ||
875 | }, | ||
876 | .read = c2port_read_flash_data, | ||
877 | .write = c2port_write_flash_data, | ||
878 | /* .size is computed at run-time */ | ||
874 | }, | 879 | }, |
875 | .read = c2port_read_flash_data, | 880 | __ATTR_NULL |
876 | .write = c2port_write_flash_data, | ||
877 | /* .size is computed at run-time */ | ||
878 | }; | 881 | }; |
879 | 882 | ||
880 | /* | 883 | /* |
@@ -907,6 +910,8 @@ struct c2port_device *c2port_device_register(char *name, | |||
907 | goto error_idr_alloc; | 910 | goto error_idr_alloc; |
908 | c2dev->id = ret; | 911 | c2dev->id = ret; |
909 | 912 | ||
913 | c2port_bin_attrs[0].size = ops->blocks_num * ops->block_size; | ||
914 | |||
910 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, | 915 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, |
911 | "c2port%d", c2dev->id); | 916 | "c2port%d", c2dev->id); |
912 | if (unlikely(IS_ERR(c2dev->dev))) { | 917 | if (unlikely(IS_ERR(c2dev->dev))) { |
@@ -919,12 +924,6 @@ struct c2port_device *c2port_device_register(char *name, | |||
919 | c2dev->ops = ops; | 924 | c2dev->ops = ops; |
920 | mutex_init(&c2dev->mutex); | 925 | mutex_init(&c2dev->mutex); |
921 | 926 | ||
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 | |||
928 | /* By default C2 port access is off */ | 927 | /* By default C2 port access is off */ |
929 | c2dev->access = c2dev->flash_access = 0; | 928 | c2dev->access = c2dev->flash_access = 0; |
930 | ops->access(c2dev, 0); | 929 | ops->access(c2dev, 0); |
@@ -937,9 +936,6 @@ struct c2port_device *c2port_device_register(char *name, | |||
937 | 936 | ||
938 | return c2dev; | 937 | return c2dev; |
939 | 938 | ||
940 | error_device_create_bin_file: | ||
941 | device_destroy(c2port_class, 0); | ||
942 | |||
943 | error_device_create: | 939 | error_device_create: |
944 | spin_lock_irq(&c2port_idr_lock); | 940 | spin_lock_irq(&c2port_idr_lock); |
945 | idr_remove(&c2port_idr, c2dev->id); | 941 | idr_remove(&c2port_idr, c2dev->id); |
@@ -959,7 +955,6 @@ void c2port_device_unregister(struct c2port_device *c2dev) | |||
959 | 955 | ||
960 | dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); | 956 | dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); |
961 | 957 | ||
962 | device_remove_bin_file(c2dev->dev, &c2port_bin_attrs); | ||
963 | spin_lock_irq(&c2port_idr_lock); | 958 | spin_lock_irq(&c2port_idr_lock); |
964 | idr_remove(&c2port_idr, c2dev->id); | 959 | idr_remove(&c2port_idr, c2dev->id); |
965 | spin_unlock_irq(&c2port_idr_lock); | 960 | spin_unlock_irq(&c2port_idr_lock); |
@@ -985,6 +980,7 @@ static int __init c2port_init(void) | |||
985 | return PTR_ERR(c2port_class); | 980 | return PTR_ERR(c2port_class); |
986 | } | 981 | } |
987 | c2port_class->dev_attrs = c2port_attrs; | 982 | c2port_class->dev_attrs = c2port_attrs; |
983 | c2port_class->dev_bin_attrs = c2port_bin_attrs; | ||
988 | 984 | ||
989 | return 0; | 985 | return 0; |
990 | } | 986 | } |