1 diff -ur lin_tape-3.0.8.orig/stmp.c lin_tape-3.0.8/stmp.c
2 --- lin_tape-3.0.8.orig/stmp.c 2016-03-17 03:52:34.000000000 +0100
3 +++ lin_tape-3.0.8/stmp.c 2016-06-19 13:10:40.664509607 +0200
6 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
7 static struct class st_sysfs_class;
8 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
9 +static const struct attribute_group *st_dev_groups[];
10 +static const struct attribute_group *st_drv_groups[];
12 static struct device_attribute st_dev_attrs[];
14 /* Paths are protected by st_index_lock */
15 static struct device *old_active_path;
16 static struct device *new_active_path;
18 static int st_probe(struct device *);
19 static int st_remove(struct device *);
21 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
22 static int do_create_sysfs_files(void);
23 static void do_remove_sysfs_files(void);
25 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
26 static int do_create_class_files(struct scsi_tape *, int, int);
32 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
33 + .groups = st_drv_groups,
38 @@ -4806,7 +4816,11 @@
39 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
40 static struct class st_sysfs_class = {
42 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
43 + .dev_groups = st_dev_groups,
45 .dev_attrs = st_dev_attrs,
50 @@ -4845,9 +4859,11 @@
54 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,13,0)
55 err = do_create_sysfs_files();
64 static void __exit exit_st(void)
66 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,13,0)
67 do_remove_sysfs_files();
69 pfo_unregister_st(&st_template.gendrv);
70 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
76 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
77 /* The sysfs driver interface. Read-only at the moment */
78 static ssize_t st_try_direct_io_show(struct device_driver *ddp, char *buf)
80 @@ -4947,10 +4966,48 @@
81 driver_remove_file(sysfs, &driver_attr_fixed_buffer_size);
82 driver_remove_file(sysfs, &driver_attr_try_direct_io);
85 +/* The sysfs driver interface. Read-only at the moment */
86 +static ssize_t try_direct_io_show(struct device_driver *ddp, char *buf)
88 + return scnprintf(buf, PAGE_SIZE, "%d\n", try_direct_io);
90 +static DRIVER_ATTR_RO(try_direct_io);
92 +static ssize_t fixed_buffer_size_show(struct device_driver *ddp, char *buf)
94 + return scnprintf(buf, PAGE_SIZE, "%d\n", st_fixed_buffer_size);
96 +static DRIVER_ATTR_RO(fixed_buffer_size);
98 +static ssize_t max_sg_segs_show(struct device_driver *ddp, char *buf)
100 + return scnprintf(buf, PAGE_SIZE, "%d\n", st_max_sg_segs);
102 +static DRIVER_ATTR_RO(max_sg_segs);
104 +static ssize_t version_show(struct device_driver *ddd, char *buf)
106 + return scnprintf(buf, PAGE_SIZE, "[%s]\n", verstr);
108 +static DRIVER_ATTR_RO(version);
110 +static struct attribute *st_drv_attrs[] = {
111 + &driver_attr_try_direct_io.attr,
112 + &driver_attr_fixed_buffer_size.attr,
113 + &driver_attr_max_sg_segs.attr,
114 + &driver_attr_version.attr,
117 +ATTRIBUTE_GROUPS(st_drv);
120 /* The sysfs simple class interface */
121 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
122 +static ssize_t lasterror_show(struct device *dev,
124 static ssize_t st_lasterror_show(struct device *dev,
126 struct device_attribute *attr, char *buf)
128 struct st_modedef *STm = dev_get_drvdata(dev);
129 @@ -4981,12 +5038,19 @@
130 STp->last_checkcondition[2]);
133 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
134 +static DEVICE_ATTR_RO(lasterror);
136 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
137 DEVICE_ATTR(lasterror, S_IRUGO, st_lasterror_show, NULL);
141 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
142 +defined_show(struct device *dev, struct device_attribute *attr, char *buf)
144 st_defined_show(struct device *dev, struct device_attribute *attr, char *buf)
147 struct st_modedef *STm = dev_get_drvdata(dev);
149 @@ -4994,13 +5058,20 @@
150 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined);
153 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
154 +static DEVICE_ATTR_RO(defined);
157 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
158 DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL);
162 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
163 +default_blksize_show(struct device *dev, struct device_attribute *attr, char *buf)
165 st_defblk_show(struct device *dev, struct device_attribute *attr, char *buf)
168 struct st_modedef *STm = dev_get_drvdata(dev);
170 @@ -5008,13 +5079,20 @@
171 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize);
174 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
175 +static DEVICE_ATTR_RO(default_blksize);
178 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
179 DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL);
183 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
184 +default_density_show(struct device *dev, struct device_attribute *attr, char *buf)
186 st_defdensity_show(struct device *dev, struct device_attribute *attr, char *buf)
189 struct st_modedef *STm = dev_get_drvdata(dev);
191 @@ -5024,13 +5102,20 @@
192 l = snprintf(buf, PAGE_SIZE, fmt, STm->default_density);
195 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
196 +static DEVICE_ATTR_RO(default_density);
199 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
200 DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL);
204 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
205 +default_compression_show(struct device *dev, struct device_attribute *attr,
207 st_defcompression_show(struct device *dev, struct device_attribute *attr,
211 struct st_modedef *STm = dev_get_drvdata(dev);
212 @@ -5039,13 +5124,20 @@
213 l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1);
216 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
217 +static DEVICE_ATTR_RO(default_compression);
220 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)
221 DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL);
225 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
226 +options_show(struct device *dev, struct device_attribute *attr, char *buf)
228 st_options_show(struct device *dev, struct device_attribute *attr, char *buf)
231 struct st_modedef *STm = dev_get_drvdata(dev);
233 @@ -5090,7 +5182,30 @@
234 l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options);
237 -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
238 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
239 +static DEVICE_ATTR_RO(options);
242 +#if LINUX_VERSION_CODE > KERNEL_VERSION(3,13,0)
243 +static struct attribute *st_dev_attrs[] = {
244 + &dev_attr_defined.attr,
245 + &dev_attr_default_blksize.attr,
246 + &dev_attr_default_density.attr,
247 + &dev_attr_default_compression.attr,
248 + &dev_attr_options.attr,
249 + &dev_attr_lasterror.attr,
253 +static struct attribute_group st_group = {
254 + .attrs = st_dev_attrs,
257 +static const struct attribute_group *st_dev_groups[] = {
261 +#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
262 static struct device_attribute st_dev_attrs[] = {
263 __ATTR_RO(st_defined),
264 __ATTR_RO(st_defblk),