struct maru_accel_data *data = container_of((struct delayed_work *)work,
struct maru_accel_data, work);
- LOG(KERN_DEBUG, "maru_accel_input_work_func starts");
+ LOG(1, "maru_accel_input_work_func starts");
memset(sensor_data, 0, __MAX_BUF_SENSOR);
poll_time = atomic_read(&data->poll_delay);
mutex_unlock(&data->data_mutex);
if (!ret) {
sscanf(sensor_data, "%d,%d,%d", &accel_x, &accel_y, &accel_z);
- LOG(KERN_INFO, "accel_set %d, %d, %d", accel_x, accel_y, accel_z);
+ LOG(1, "accel_set %d, %d, %d", accel_x, accel_y, accel_z);
input_report_rel(data->input_data, REL_RX, accel_x);
input_report_rel(data->input_data, REL_RY, accel_y);
enable = atomic_read(&data->enable);
mutex_unlock(&data->data_mutex);
- LOG(KERN_DEBUG, "enable: %d, poll_time: %d", enable, poll_time);
+ LOG(1, "enable: %d, poll_time: %d", enable, poll_time);
if (enable) {
if (poll_time > 0) {
schedule_delayed_work(&data->work, nsecs_to_jiffies(poll_time));
}
}
- LOG(KERN_DEBUG, "maru_accel_input_work_func ends");
+ LOG(1, "maru_accel_input_work_func ends");
}
ret = get_sensor_data(sensor_type_accel_delay, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial delay time");
+ ERR("failed to get initial delay time");
return ret;
}
ret = get_sensor_data(sensor_type_accel_enable, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial enable");
+ ERR("failed to get initial enable");
return ret;
}
enable = sensor_atoi(sensor_data);
if (delay < 0) {
- LOG(KERN_ERR, "weird value is set initial delay");
+ ERR("weird value is set initial delay");
return ret;
}
input_data = input_allocate_device();
if (input_data == NULL) {
- LOG(KERN_ERR, "failed initialing input handler");
+ ERR("failed initialing input handler");
accel_clear(data);
return -ENOMEM;
}
ret = input_register_device(input_data);
if (ret) {
- LOG(KERN_ERR, "failed to register input data");
+ ERR("failed to register input data");
accel_clear(data);
return ret;
}
&maru_accel_attribute_group);
if (ret) {
accel_clear(data);
- LOG(KERN_ERR, "failed initialing devices");
+ ERR("failed initialing devices");
return ret;
}
int ret = 0;
struct maru_accel_data *data = NULL;
- LOG(KERN_INFO, "maru_accel device init starts.");
+ INFO("maru_accel device init starts.");
data = kmalloc(sizeof(struct maru_accel_data), GFP_KERNEL);
if (data == NULL) {
- LOG(KERN_ERR, "failed to create accel data.");
+ ERR("failed to create accel data.");
return -ENOMEM;
}
ret = register_sensor_device(accel_sensor_device, vs,
accel_sensor_attrs, DRIVER_ACCEL_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register accel device");
+ ERR("failed to register accel device");
accel_clear(data);
return -1;
}
ret = l_register_sensor_device(l_accel_sensor_device, vs,
l_accel_sensor_attrs, DRIVER_ACCEL_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register legacy accel device");
+ ERR("failed to register legacy accel device");
accel_clear(data);
return -1;
}
// create input
ret = create_input_device(data);
if (ret) {
- LOG(KERN_ERR, "failed to create input device");
+ ERR("failed to create input device");
return ret;
}
// set initial delay & enable
ret = set_initial_value(data);
if (ret) {
- LOG(KERN_ERR, "failed to set initial value");
+ ERR("failed to set initial value");
return ret;
}
- LOG(KERN_INFO, "maru_accel device init ends.");
+ INFO("maru_accel device init ends.");
return ret;
}
struct maru_geo_data *data = container_of((struct delayed_work *)work,
struct maru_geo_data, work);
- LOG(KERN_DEBUG, "maru_geo_input_work_func starts");
+ LOG(1, "maru_geo_input_work_func starts");
memset(sensor_data, 0, __MAX_BUF_SENSOR);
poll_time = atomic_read(&data->poll_delay);
mutex_unlock(&data->data_mutex);
if (!ret) {
sscanf(sensor_data, "%d %d %d %d", &geo_x, &geo_y, &geo_z, &hdst);
- LOG(KERN_INFO, "geo_set %d, %d, %d, %d", geo_x, geo_y, geo_z, hdst);
+ LOG(1, "geo_set %d, %d, %d, %d", geo_x, geo_y, geo_z, hdst);
input_report_rel(data->input_data, REL_RX, geo_x);
input_report_rel(data->input_data, REL_RY, geo_y);
enable = atomic_read(&data->enable);
mutex_unlock(&data->data_mutex);
- LOG(KERN_DEBUG, "enable: %d, poll_time: %d", enable, poll_time);
+ LOG(1, "enable: %d, poll_time: %d", enable, poll_time);
if (enable) {
if (poll_time > 0) {
schedule_delayed_work(&data->work, nsecs_to_jiffies(poll_time));
}
}
- LOG(KERN_DEBUG, "maru_geo_input_work_func ends");
+ LOG(1, "maru_geo_input_work_func ends");
}
ret = get_sensor_data(sensor_type_geo_delay, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial delay time");
+ ERR("failed to get initial delay time");
return ret;
}
ret = get_sensor_data(sensor_type_geo_enable, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial enable");
+ ERR("failed to get initial enable");
return ret;
}
enable = sensor_atoi(sensor_data);
if (delay < 0) {
- LOG(KERN_ERR, "weird value is set initial delay");
+ ERR("weird value is set initial delay");
return ret;
}
input_data = input_allocate_device();
if (input_data == NULL) {
- LOG(KERN_ERR, "failed initialing input handler");
+ ERR("failed initialing input handler");
geo_clear(data);
return -ENOMEM;
}
ret = input_register_device(input_data);
if (ret) {
- LOG(KERN_ERR, "failed to register input data");
+ ERR("failed to register input data");
geo_clear(data);
return ret;
}
&maru_geo_attribute_group);
if (ret) {
geo_clear(data);
- LOG(KERN_ERR, "failed initialing devices");
+ ERR("failed initialing devices");
return ret;
}
int ret = 0;
struct maru_geo_data *data = NULL;
- LOG(KERN_INFO, "maru_geo device init starts.");
+ INFO("maru_geo device init starts.");
data = kmalloc(sizeof(struct maru_geo_data), GFP_KERNEL);
if (data == NULL) {
- LOG(KERN_ERR, "failed to create geo data.");
+ ERR("failed to create geo data.");
return -ENOMEM;
}
ret = register_sensor_device(geo_sensor_device, vs,
geo_sensor_attrs, DRIVER_GEO_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register geo device");
+ ERR("failed to register geo device");
geo_clear(data);
return -1;
}
ret = l_register_sensor_device(l_geo_sensor_device, vs,
l_geo_sensor_attrs, DRIVER_GEO_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register legacy geo device");
+ ERR("failed to register legacy geo device");
geo_clear(data);
return -1;
}
// create input
ret = create_input_device(data);
if (ret) {
- LOG(KERN_ERR, "failed to create input device");
+ ERR("failed to create input device");
return ret;
}
// set initial delay & enable
ret = set_initial_value(data);
if (ret) {
- LOG(KERN_ERR, "failed to set initial value");
+ ERR("failed to set initial value");
return ret;
}
- LOG(KERN_INFO, "maru_geo device init ends.");
+ INFO("maru_geo device init ends.");
return ret;
}
struct maru_gyro_data *data = container_of((struct delayed_work *)work,
struct maru_gyro_data, work);
- LOG(KERN_DEBUG, "maru_gyro_input_work_func starts");
+ LOG(1, "maru_gyro_input_work_func starts");
memset(sensor_data, 0, __MAX_BUF_SENSOR);
poll_time = atomic_read(&data->poll_delay);
mutex_unlock(&data->data_mutex);
if (!ret) {
sscanf(sensor_data, "%d,%d,%d", &gyro_x, &gyro_y, &gyro_z);
- LOG(KERN_INFO, "gyro_set %d, %d, %d", gyro_x, gyro_y, gyro_z);
+ LOG(1, "gyro_set %d, %d, %d", gyro_x, gyro_y, gyro_z);
input_report_rel(data->input_data, REL_RX, gyro_x);
input_report_rel(data->input_data, REL_RY, gyro_y);
enable = atomic_read(&data->enable);
mutex_unlock(&data->data_mutex);
- LOG(KERN_DEBUG, "enable: %d, poll_time: %d", enable, poll_time);
+ LOG(1, "enable: %d, poll_time: %d", enable, poll_time);
if (enable) {
if (poll_time > 0) {
schedule_delayed_work(&data->work, nsecs_to_jiffies(poll_time));
}
}
- LOG(KERN_DEBUG, "maru_gyro_input_work_func ends");
+ LOG(1, "maru_gyro_input_work_func ends");
}
ret = get_sensor_data(sensor_type_gyro_delay, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial delay time");
+ ERR("failed to get initial delay time");
return ret;
}
ret = get_sensor_data(sensor_type_gyro_enable, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial enable");
+ ERR("failed to get initial enable");
return ret;
}
enable = sensor_atoi(sensor_data);
if (delay < 0) {
- LOG(KERN_ERR, "weird value is set initial delay");
+ ERR("weird value is set initial delay");
return ret;
}
input_data = input_allocate_device();
if (input_data == NULL) {
- LOG(KERN_ERR, "failed initialing input handler");
+ ERR("failed initialing input handler");
gyro_clear(data);
return -ENOMEM;
}
ret = input_register_device(input_data);
if (ret) {
- LOG(KERN_ERR, "failed to register input data");
+ ERR("failed to register input data");
gyro_clear(data);
return ret;
}
&maru_gyro_attribute_group);
if (ret) {
gyro_clear(data);
- LOG(KERN_ERR, "failed initialing devices");
+ ERR("failed initialing devices");
return ret;
}
int ret = 0;
struct maru_gyro_data *data = NULL;
- LOG(KERN_INFO, "maru_gyro device init starts.");
+ INFO("maru_gyro device init starts.");
data = kmalloc(sizeof(struct maru_gyro_data), GFP_KERNEL);
if (data == NULL) {
- LOG(KERN_ERR, "failed to create gyro data.");
+ ERR("failed to create gyro data.");
return -ENOMEM;
}
ret = register_sensor_device(gyro_sensor_device, vs,
gyro_sensor_attrs, DRIVER_GYRO_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register gyro device");
+ ERR("failed to register gyro device");
gyro_clear(data);
return -1;
}
ret = l_register_sensor_device(l_gyro_sensor_device, vs,
l_gyro_sensor_attrs, DRIVER_GYRO_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register legacy gyro device");
+ ERR("failed to register legacy gyro device");
gyro_clear(data);
return -1;
}
// create input
ret = create_input_device(data);
if (ret) {
- LOG(KERN_ERR, "failed to create input device");
+ ERR("failed to create input device");
return ret;
}
// set initial delay & enable
ret = set_initial_value(data);
if (ret) {
- LOG(KERN_ERR, "failed to set initial value");
+ ERR("failed to set initial value");
return ret;
}
- LOG(KERN_INFO, "maru_gyro device init ends.");
+ INFO("maru_gyro device init ends.");
return ret;
}
static int maru_upload_effect(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old)
{
- LOG(KERN_INFO, "called maru_upload_effect. No work to do.");
+ INFO("called maru_upload_effect. No work to do.");
return 0;
}
static int maru_erase_effect(struct input_dev *dev, int effect_id)
{
- LOG(KERN_INFO, "called maru_erase_effect. No work to do.");
+ INFO("called maru_erase_effect. No work to do.");
return 0;
}
static int maru_playback(struct input_dev *dev, int effect_id, int value)
{
- LOG(KERN_INFO, "called maru_playback. No work to do.");
+ INFO("called maru_playback. No work to do.");
return 0;
}
input_data = input_allocate_device();
if (input_data == NULL) {
- LOG(KERN_ERR, "failed initialing input handler");
+ ERR("failed initialing input handler");
haptic_clear(data);
return -ENOMEM;
}
ret = input_register_device(input_data);
if (ret) {
- LOG(KERN_ERR, "failed to register input data");
+ ERR("failed to register input data");
haptic_clear(data);
return ret;
}
int ret = 0;
struct maru_haptic_data *data = NULL;
- LOG(KERN_INFO, "maru_haptic device init starts.");
+ INFO("maru_haptic device init starts.");
data = kmalloc(sizeof(struct maru_haptic_data), GFP_KERNEL);
if (data == NULL) {
- LOG(KERN_ERR, "failed to create haptic data.");
+ ERR("failed to create haptic data.");
return -ENOMEM;
}
// create input
ret = create_input_device(data);
if (ret) {
- LOG(KERN_ERR, "failed to create input device");
+ ERR("failed to create input device");
return ret;
}
- LOG(KERN_INFO, "maru_haptic device init ends.");
+ INFO("maru_haptic device init ends.");
return ret;
}
struct maru_light_data *data = container_of((struct delayed_work *)work,
struct maru_light_data, work);
- LOG(KERN_DEBUG, "maru_light_input_work_func starts");
+ LOG(1, "maru_light_input_work_func starts");
memset(sensor_data, 0, __MAX_BUF_SENSOR);
poll_time = atomic_read(&data->poll_delay);
mutex_unlock(&data->data_mutex);
if (!ret) {
sscanf(sensor_data, "%d", &light);
- LOG(KERN_INFO, "light_set %d", light);
+ LOG(1, "light_set %d", light);
input_report_rel(data->input_data, REL_RX, light); // LUX
input_report_rel(data->input_data, REL_HWHEEL, 0); // red
enable = atomic_read(&data->enable);
mutex_unlock(&data->data_mutex);
- LOG(KERN_DEBUG, "enable: %d, poll_time: %d", enable, poll_time);
+ LOG(1, "enable: %d, poll_time: %d", enable, poll_time);
if (enable) {
if (poll_time > 0) {
schedule_delayed_work(&data->work, nsecs_to_jiffies(poll_time));
}
}
- LOG(KERN_DEBUG, "maru_light_input_work_func ends");
+ LOG(1, "maru_light_input_work_func ends");
}
ret = get_sensor_data(sensor_type_light_delay, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial delay time");
+ ERR("failed to get initial delay time");
return ret;
}
ret = get_sensor_data(sensor_type_light_enable, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial enable");
+ ERR("failed to get initial enable");
return ret;
}
enable = sensor_atoi(sensor_data);
if (delay < 0) {
- LOG(KERN_ERR, "weird value is set initial delay");
+ ERR("weird value is set initial delay");
return ret;
}
input_data = input_allocate_device();
if (input_data == NULL) {
- LOG(KERN_ERR, "failed initialing input handler");
+ ERR("failed initialing input handler");
light_clear(data);
return -ENOMEM;
}
ret = input_register_device(input_data);
if (ret) {
- LOG(KERN_ERR, "failed to register input data");
+ ERR("failed to register input data");
light_clear(data);
return ret;
}
&maru_light_attribute_group);
if (ret) {
light_clear(data);
- LOG(KERN_ERR, "failed initialing devices");
+ ERR("failed initialing devices");
return ret;
}
int ret = 0;
struct maru_light_data *data = NULL;
- LOG(KERN_INFO, "maru_light device init starts.");
+ INFO("maru_light device init starts.");
data = kmalloc(sizeof(struct maru_light_data), GFP_KERNEL);
if (data == NULL) {
- LOG(KERN_ERR, "failed to create light data.");
+ ERR("failed to create light data.");
return -ENOMEM;
}
ret = register_sensor_device(light_sensor_device, vs,
light_sensor_attrs, DRIVER_LIGHT_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register light device");
+ ERR("failed to register light device");
light_clear(data);
return -1;
}
ret = l_register_sensor_device(l_light_sensor_device, vs,
l_light_sensor_attrs, DRIVER_LIGHT_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register legacy light device");
+ ERR("failed to register legacy light device");
light_clear(data);
return -1;
}
// create input
ret = create_input_device(data);
if (ret) {
- LOG(KERN_ERR, "failed to create input device");
+ ERR("failed to create input device");
return ret;
}
// set initial delay & enable
ret = set_initial_value(data);
if (ret) {
- LOG(KERN_ERR, "failed to set initial value");
+ ERR("failed to set initial value");
return ret;
}
- LOG(KERN_INFO, "maru_light device init ends.");
+ INFO("maru_light device init ends.");
return ret;
}
struct maru_proxi_data *data = container_of((struct delayed_work *)work,
struct maru_proxi_data, work);
- LOG(KERN_DEBUG, "maru_proxi_input_work_func starts");
+ LOG(1, "maru_proxi_input_work_func starts");
memset(sensor_data, 0, __MAX_BUF_SENSOR);
poll_time = atomic_read(&data->poll_delay);
sscanf(sensor_data, "%d", &proxi);
if (proxi)
proxi = 1;
- LOG(KERN_INFO, "proxi_set %d", proxi);
+ LOG(1, "proxi_set %d", proxi);
input_report_rel(data->input_data, ABS_DISTANCE, proxi);
input_sync(data->input_data);
enable = atomic_read(&data->enable);
mutex_unlock(&data->data_mutex);
- LOG(KERN_DEBUG, "enable: %d, poll_time: %d", enable, poll_time);
+ LOG(1, "enable: %d, poll_time: %d", enable, poll_time);
if (enable) {
if (poll_time > 0) {
schedule_delayed_work(&data->work, nsecs_to_jiffies(poll_time));
}
}
- LOG(KERN_DEBUG, "maru_proxi_input_work_func ends");
+ LOG(1, "maru_proxi_input_work_func ends");
}
ret = get_sensor_data(sensor_type_proxi_delay, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial delay time");
+ ERR("failed to get initial delay time");
return ret;
}
ret = get_sensor_data(sensor_type_proxi_enable, sensor_data);
if (ret) {
- LOG(KERN_ERR, "failed to get initial enable");
+ ERR("failed to get initial enable");
return ret;
}
enable = sensor_atoi(sensor_data);
if (delay < 0) {
- LOG(KERN_ERR, "weird value is set initial delay");
+ ERR("weird value is set initial delay");
return ret;
}
input_data = input_allocate_device();
if (input_data == NULL) {
- LOG(KERN_ERR, "failed initialing input handler");
+ ERR("failed initialing input handler");
proxi_clear(data);
return -ENOMEM;
}
ret = input_register_device(input_data);
if (ret) {
- LOG(KERN_ERR, "failed to register input data");
+ ERR("failed to register input data");
proxi_clear(data);
return ret;
}
&maru_proxi_attribute_group);
if (ret) {
proxi_clear(data);
- LOG(KERN_ERR, "failed initialing devices");
+ ERR("failed initialing devices");
return ret;
}
int ret = 0;
struct maru_proxi_data *data = NULL;
- LOG(KERN_INFO, "maru_proxi device init starts.");
+ INFO("maru_proxi device init starts.");
data = kmalloc(sizeof(struct maru_proxi_data), GFP_KERNEL);
if (data == NULL) {
- LOG(KERN_ERR, "failed to create proxi data.");
+ ERR("failed to create proxi data.");
return -ENOMEM;
}
ret = register_sensor_device(proxi_sensor_device, vs,
proxi_sensor_attrs, DRIVER_PROXI_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register proxi device");
+ ERR("failed to register proxi device");
proxi_clear(data);
return -1;
}
ret = l_register_sensor_device(l_proxi_sensor_device, vs,
l_proxi_sensor_attrs, DRIVER_PROXI_NAME);
if (ret) {
- LOG(KERN_ERR, "failed to register legacy proxi device");
+ ERR("failed to register legacy proxi device");
proxi_clear(data);
return -1;
}
// create input
ret = create_input_device(data);
if (ret) {
- LOG(KERN_ERR, "failed to create input device");
+ ERR("failed to create input device");
return ret;
}
// set initial delay & enable
ret = set_initial_value(data);
if (ret) {
- LOG(KERN_ERR, "failed to set initial value");
+ ERR("failed to set initial value");
return ret;
}
- LOG(KERN_INFO, "maru_proxi device init ends.");
+ INFO("maru_proxi device init ends.");
return ret;
}
#include "maru_virtio_sensor.h"
+int sensor_driver_debug = 0;
+module_param(sensor_driver_debug, int, 0644);
+MODULE_PARM_DESC(sensor_driver_debug, "Turn on/off maru sensor debugging (default:off).");
+
static struct virtio_device_id id_table[] = { { VIRTIO_ID_SENSOR,
VIRTIO_DEV_ANY_ID }, { 0 }, };
int i = 0, err = 0;
if (!vs->sensor_class) {
- LOG(KERN_ERR, "sensor class is not created before make device");
+ ERR("sensor class is not created before make device");
return -1;
}
- LOG(KERN_INFO, "device creation: %s.", name);
+ INFO("device creation: %s.", name);
dev = device_create(vs->sensor_class, NULL, 0, NULL, "%s", name);
if (dev < 0) {
- LOG(KERN_ERR, "register_device_create failed!");
+ ERR("register_device_create failed!");
return -1;
}
if (attributes == NULL) {
- LOG(KERN_ERR, "attributes is NULL.");
+ ERR("attributes is NULL.");
return -1;
}
for (i = 0; attributes[i] != NULL; i++) {
if ((err = device_create_file(dev, attributes[i])) < 0) {
- LOG(KERN_ERR, "failed to create device file with attribute[%d - %d]", i, err);
+ ERR("failed to create device file with attribute[%d - %d]", i, err);
return -1;
}
}
- LOG(KERN_INFO, "register_sensor_device ends: %s.", name);
+ INFO("register_sensor_device ends: %s.", name);
return 0;
}
int i = 0, err = 0;
if (!vs->l_sensor_class) {
- LOG(KERN_ERR, "l sensor class is not created before make device");
+ ERR("l sensor class is not created before make device");
return -1;
}
dev = device_create(vs->l_sensor_class, NULL, 0, NULL, "%s", name);
if (dev < 0) {
- LOG(KERN_ERR, "legacy register_device_create failed!");
+ ERR("legacy register_device_create failed!");
return -1;
}
if (attributes == NULL) {
- LOG(KERN_ERR, "l sensor attributes is NULL.");
+ ERR("l sensor attributes is NULL.");
return -1;
}
for (i = 0; attributes[i] != NULL; i++) {
if ((err = device_create_file(dev, attributes[i])) < 0) {
- LOG(KERN_ERR, "failed to create legacy device file with attribute[%d - %d]", i, err);
+ ERR("failed to create legacy device file with attribute[%d - %d]", i, err);
return -1;
}
}
msg = (struct msg_info*) virtqueue_get_buf(vs->vq, &len);
if (msg == NULL) {
- LOG(KERN_ERR, "failed to virtqueue_get_buf");
+ ERR("failed to virtqueue_get_buf");
return;
}
if (msg->req != request_answer) {
- LOG(KERN_DEBUG, "receive queue- not an answer message: %d", msg->req);
+ LOG(1, "receive queue- not an answer message: %d", msg->req);
return;
}
if (msg->buf == NULL) {
- LOG(KERN_ERR, "receive queue- message from host is NULL.");
+ ERR("receive queue- message from host is NULL.");
return;
}
- LOG(KERN_DEBUG, "msg buf: %s, req: %d, type: %d", msg->buf, msg->req, msg->type);
+ LOG(1, "msg buf: %s, req: %d, type: %d", msg->buf, msg->req, msg->type);
mutex_lock(&vs->lock);
memset(sensor_data, 0, __MAX_BUF_SENSOR);
int err = 0;
if (buf == NULL) {
- LOG(KERN_ERR, "set_sensor buf is NULL.");
+ ERR("set_sensor buf is NULL.");
return;
}
if (vs == NULL) {
- LOG(KERN_ERR, "Invalid sensor handle");
+ ERR("Invalid sensor handle");
return;
}
strcpy(vs->msginfo.buf, buf);
mutex_unlock(&vs->lock);
- LOG(KERN_DEBUG, "set_sensor_data type: %d, req: %d, buf: %s",
+ LOG(1, "set_sensor_data type: %d, req: %d, buf: %s",
vs->msginfo.type, vs->msginfo.req, vs->msginfo.buf);
err = virtqueue_add_outbuf(vs->vq, vs->sg_vq, 1, &vs->msginfo, GFP_ATOMIC);
if (err < 0) {
- LOG(KERN_ERR, "failed to add buffer to virtqueue (err = %d)", err);
+ ERR("failed to add buffer to virtqueue (err = %d)", err);
return;
}
int err = 0;
if (vs == NULL || data == NULL) {
- LOG(KERN_ERR, "Invalid sensor handle or data is NULL.");
+ ERR("Invalid sensor handle or data is NULL.");
return -1;
}
vs->msginfo.type = type;
mutex_unlock(&vs->lock);
- LOG(KERN_DEBUG, "get_sensor_data type: %d, req: %d",
+ LOG(1, "get_sensor_data type: %d, req: %d",
vs->msginfo.type, vs->msginfo.req);
sgs[0] = &vs->sg_vq[0];
sgs[1] = &vs->sg_vq[1];
err = virtqueue_add_sgs(vs->vq, sgs, 1, 1, &vs->msginfo, GFP_ATOMIC);
if (err < 0) {
- LOG(KERN_ERR, "failed to add buffer to virtqueue (err = %d)", err);
+ ERR("failed to add buffer to virtqueue (err = %d)", err);
return err;
}
int index = 0;
char sensor_data[__MAX_BUF_SENSOR];
- LOG(KERN_INFO, "Sensor probe starts");
+ INFO("Sensor probe starts");
vs = kmalloc(sizeof(struct virtio_sensor), GFP_KERNEL);
if (!vs) {
- LOG(KERN_ERR, "failed to allocate sensor structure.");
+ ERR("failed to allocate sensor structure.");
return -ENOMEM;
}
vs->sensor_class = class_create(THIS_MODULE, SENSOR_CLASS_NAME);
if (IS_ERR(vs->sensor_class)) {
- LOG(KERN_ERR, "sensor class creation is failed.");
+ ERR("sensor class creation is failed.");
return PTR_ERR(vs->sensor_class);
}
#ifdef SUPPORT_LEGACY_SENSOR
vs->l_sensor_class = class_create(THIS_MODULE, L_SENSOR_CLASS_NAME);
if (IS_ERR(vs->sensor_class)) {
- LOG(KERN_ERR, "sensor class creation is failed.");
+ ERR("sensor class creation is failed.");
return PTR_ERR(vs->sensor_class);
}
#endif
vs->vq = virtio_find_single_vq(dev, sensor_vq_done, "sensor");
if (IS_ERR(vs->vq)) {
cleanup(dev);
- LOG(KERN_ERR, "failed to init virt queue");
+ ERR("failed to init virt queue");
return ret;
}
memset(sensor_data, 0, __MAX_BUF_SENSOR);
ret = get_sensor_data(sensor_type_list, sensor_data);
if (ret) {
- LOG(KERN_ERR, "sensor capability data is null.");
+ ERR("sensor capability data is null.");
cleanup(dev);
return ret;
}
vs->sensor_capability = sensor_atoi(sensor_data);
- LOG(KERN_INFO, "sensor capability is %02x", vs->sensor_capability);
+ INFO("sensor capability is %02x", vs->sensor_capability);
ret = device_init(vs);
if (ret) {
- LOG(KERN_ERR, "failed initialing devices");
+ ERR("failed initialing devices");
cleanup(dev);
return ret;
}
- LOG(KERN_INFO, "Sensor probe completes");
+ INFO("Sensor probe completes");
return ret;
}
struct virtio_sensor* vs = dev->priv;
if (!vs)
{
- LOG(KERN_ERR, "vs is NULL");
+ ERR("vs is NULL");
return;
}
cleanup(dev);
- LOG(KERN_INFO, "Sensor driver is removed.");
+ INFO("Sensor driver is removed.");
}
MODULE_DEVICE_TABLE(virtio, id_table);
static int __init sensor_init(void)
{
- LOG(KERN_INFO, "Sensor driver initialized.");
+ INFO("Sensor driver initialized.");
return register_virtio_driver(&virtio_sensor_driver);
}
{
unregister_virtio_driver(&virtio_sensor_driver);
- LOG(KERN_INFO, "Sensor driver is destroyed.");
+ INFO("Sensor driver is destroyed.");
}
module_init(sensor_init);
#define SENSOR_HAPTIC_INPUT_NAME "haptic_sensor"
+// It locates /sys/module/maru_virtio_sensor/parameters/sensor_driver_debug
+extern int sensor_driver_debug;
+
+#define ERR(fmt, ...) \
+ printk(KERN_ERR "%s: " fmt "\n", SENSOR_CLASS_NAME, ##__VA_ARGS__)
+
+#define INFO(fmt, ...) \
+ printk(KERN_INFO "%s: " fmt "\n", SENSOR_CLASS_NAME, ##__VA_ARGS__)
+
#define LOG(log_level, fmt, ...) \
- printk(log_level "%s: " fmt "\n", SENSOR_CLASS_NAME, ##__VA_ARGS__)
+ do { \
+ if (sensor_driver_debug >= (log_level)) { \
+ printk(KERN_INFO "%s: " fmt "\n", SENSOR_CLASS_NAME, ##__VA_ARGS__); \
+ } \
+ } while (0)
/*
* Accelerometer device