#define TGL_DEV_NAME "tgl"
+#define TGL_VERSION_MAJOR 1
+#define TGL_VERSION_MINOR 1
+
#define TGL_HASH_BITS 4
#define TGL_HASH_BUCKETS (1 << TGL_HASH_BITS)
/**
* struct tgl_device - tgl device structure
* @dev: (misc )device pointer
+ * @version: version data
* @heads: hash heads for global node data
* @lock: lock for hash heads
*/
static struct tgl_device {
struct device *dev;
+ struct tgl_ver_data version;
+
struct hlist_head heads[TGL_HASH_BUCKETS];
struct mutex lock;
} tgl;
return found;
}
+static int tgl_get_version(struct tgl_session *session, void __user *arg)
+{
+ struct tgl_ver_data ver_data;
+
+ memcpy(&ver_data, &tgl.version, sizeof(ver_data));
+
+ if (copy_to_user(arg, &ver_data, sizeof(ver_data)))
+ return -EFAULT;
+
+ return 0;
+}
+
static int tgl_register(struct tgl_session *session, void __user *arg)
{
struct tgl_reg_data reg_data;
}
/* add to waiter */
- INIT_LIST_HEAD(&wait_node.node);
mutex_lock(&data->lock);
list_add_tail(&wait_node.node, &data->list);
mutex_unlock(&data->lock);
node = tgl_find_node(session->heads, lock_data.key);
if (node) {
/* check waiter */
- tgl_remove_wait_node(data, session);
+ tgl_remove_wait_node(node->data, session);
mutex_unlock(&session->lock);
return 0;
}
int ret;
switch (cmd) {
+ case TGL_IOCTL_GET_VERSION:
+ ret = tgl_get_version(session, (void __user *)arg);
+ if (ret)
+ dev_err(tgl.dev,
+ "%s: failed to get version[%d]\n",
+ __func__, ret);
case TGL_IOCTL_REGISTER:
ret = tgl_register(session, (void __user *)arg);
if (ret)
break;
default:
dev_err(tgl.dev,
- "%s: failed to call ioctl: tgid[%d]\n",
- __func__, task_tgid_nr(current));
+ "%s: failed to call ioctl: tgid[%d]:0x%x\n",
+ __func__, task_tgid_nr(current), cmd);
ret = -ENOTTY;
break;
}
static int __init tgl_init(void)
{
+ struct tgl_ver_data *version = &tgl.version;
int ret, i;
+ version->major = TGL_VERSION_MAJOR;
+ version->minor = TGL_VERSION_MINOR;
+
ret = misc_register(&tgl_misc_device);
if (ret) {
pr_err("%s: failed to register misc device[%d]\n",
* by the Free Software Foundation.
*/
-#ifndef __TGL__
-#define __TGL__
+#ifndef __TIZEN_GLOBAL_LOOK_H__
+#define __TIZEN_GLOBAL_LOOK_H__
#define TGL_IOCTL_BASE 0x32
#define TGL_IO(nr) _IO(TGL_IOCTL_BASE, nr)
#define TGL_IOWR(nr, type) _IOWR(TGL_IOCTL_BASE, nr, type)
/**
+ * struct tgl_ver_data - tgl version data structure
+ * @major: major version
+ * @minor: minor version
+ */
+struct tgl_ver_data {
+ unsigned int major;
+ unsigned int minor;
+};
+
+/**
* struct tgl_reg_data - tgl register data structure
* @key: lookup key
* @timeout_ms: timeout value for waiting event
};
enum {
- _TGL_REGISTER = 1,
+ _TGL_GET_VERSION,
+ _TGL_REGISTER,
_TGL_UNREGISTER,
_TGL_LOCK,
_TGL_UNLOCK,
_TGL_GET_DATA,
};
+/* get version information */
+#define TGL_IOCTL_GET_VERSION TGL_IOR(_TGL_GET_VERSION, struct tgl_ver_data)
/* register key */
#define TGL_IOCTL_REGISTER TGL_IOW(_TGL_REGISTER, struct tgl_reg_data)
/* unregister key */
/* get user data with key */
#define TGL_IOCTL_GET_DATA TGL_IOR(_TGL_GET_DATA, struct tgl_usr_data)
-#endif /* __TGL__ */
+#endif /* __TIZEN_GLOBAL_LOOK_H__ */