Commit 70befd18 authored by Alessandro Rubini's avatar Alessandro Rubini

core: don't use the binary control for 2.6.34 and earlier

While the binary control file in sysfs is a neat feature, the
interface to binary attributes was different before 2.6.35. This
allows compiling with no warnings (and no crashes if the feature is
used) by just disabling the attribute at compile time.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent b428f4b8
......@@ -547,10 +547,13 @@ static int chan_register(struct zio_channel *chan, struct zio_channel *chan_t)
err = device_register(&chan->head.dev);
if (err)
goto out_ctrl_bits;
/* Create the sysfs binary file for the current control */
err = sysfs_create_bin_file(&chan->head.dev.kobj, &zio_attr_cur_ctrl);
if (err)
goto out_bin_attr;
if (ZIO_HAS_BINARY_CONTROL) {
/* Create the sysfs binary file for the current control */
err = sysfs_create_bin_file(&chan->head.dev.kobj,
&zio_attr_cur_ctrl);
if (err)
goto out_bin_attr;
}
/* Create buffer */
bi = __bi_create_and_init(chan->cset->zbuf, chan);
if (IS_ERR(bi)) {
......@@ -574,7 +577,8 @@ out_cdev_create:
out_buf_reg:
__bi_destroy(chan->cset->zbuf, bi);
out_buf_create:
sysfs_remove_bin_file(&chan->head.dev.kobj, &zio_attr_cur_ctrl);
if (ZIO_HAS_BINARY_CONTROL)
sysfs_remove_bin_file(&chan->head.dev.kobj, &zio_attr_cur_ctrl);
out_bin_attr:
device_unregister(&chan->head.dev);
out_ctrl_bits:
......@@ -597,7 +601,8 @@ static void chan_unregister(struct zio_channel *chan)
/* destroy buffer instance */
__bi_unregister(chan->cset->zbuf, chan->bi);
__bi_destroy(chan->cset->zbuf, chan->bi);
sysfs_remove_bin_file(&chan->head.dev.kobj, &zio_attr_cur_ctrl);
if (ZIO_HAS_BINARY_CONTROL)
sysfs_remove_bin_file(&chan->head.dev.kobj, &zio_attr_cur_ctrl);
device_unregister(&chan->head.dev);
zio_free_control(chan->current_ctrl);
zattr_set_remove(&chan->head);
......
......@@ -14,6 +14,7 @@
#include <linux/device.h>
#include <linux/spinlock.h>
#include <linux/sysfs.h>
#include <linux/version.h>
#include <linux/zio.h>
#include <linux/zio-sysfs.h>
......@@ -535,6 +536,7 @@ static ssize_t zattr_store(struct device *dev, struct device_attribute *attr,
return count;
}
#if ZIO_HAS_BINARY_CONTROL
/*
* zobj_read_cur_ctrl
* it returns the current control to userspace through binary sysfs file
......@@ -567,6 +569,7 @@ struct bin_attribute zio_attr_cur_ctrl = {
.size = ZIO_CONTROL_SIZE, /* Will be modified for TLV support */
.read = zobj_read_cur_ctrl,
};
#endif /* ZIO_HAS_BINARY_CONTROL */
/* default zio attributes */
static struct device_attribute zio_default_attributes[] = {
......
#ifndef ZIO_INTERNAL_H_
#define ZIO_INTERNAL_H_
#include <linux/version.h>
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
#define ZIO_HAS_BINARY_CONTROL 1
#else
#define ZIO_HAS_BINARY_CONTROL 0
#endif
/* Defined in zio-sys.c */
extern struct device_type zdev_generic_type;
extern struct device_type zobj_device_type;
......
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