ksudoku/ksudoku.c

75 lines
1.7 KiB
C
Raw Normal View History

#include "ksudoku.h"
2020-03-31 18:57:03 +01:00
#define KSUDOKU_VERSION "0.1"
#define KSUDOKU_DESC "Kernel Sudoku Module"
2020-03-31 18:57:03 +01:00
static SUDOKU_ATTR_RO(is_valid);
static SUDOKU_ATTR_RO(is_solved);
/**
* sudoku_create_file - create sysfs attribute file for the given sudoku.
* @sudoku: sudoku
* @attr: sudoku attribute descriptor.
*/
int sudoku_create_file(struct sudoku *s,
const struct sudoku_attribute *attr)
{
int error = 0;
if (s) {
WARN(((attr->attr.mode & S_IWUGO) && !attr->store),
"Attribute %s: write permission without 'store'\n",
attr->attr.name);
WARN(((attr->attr.mode & S_IRUGO) && !attr->show),
"Attribute %s: read permission without 'show'\n",
attr->attr.name);
error = sysfs_create_file(&s->kobj, &attr->attr);
}
return error;
}
EXPORT_SYMBOL_GPL(sudoku_create_file);
/* static ssize_t is_valid_show(struct kobject *kobj, struct attribute *attr, */
/* char *buf) */
/* { */
/* struct sudoku_attribute *s_attr = to_sudoku_attr(attr); */
/* struct sudoku *s = to_sudoku(kobj); */
/* ssize_t ret = -EIO; */
/* if (s_attr->show) */
/* ret = s_attr->show(s, s_attr, buf); */
/* if (ret >= (ssize_t)PAGE_SIZE) { */
/* printk("is_valid_show: %pS returned bad count\n", */
/* s_attr->show); */
/* } */
/* return ret; */
/* } */
static int ksudoku_init(void)
2020-03-31 18:57:03 +01:00
{
printk(KERN_ALERT "Init ksudoku.\n");
return 0;
}
static void ksudoku_exit(void)
2020-03-31 18:57:03 +01:00
{
printk(KERN_ALERT "Exit ksudoku.\n");
}
MODULE_AUTHOR("Sameer Rahmani <lxsameer@gnu.org>");
MODULE_DESCRIPTION(KSUDOKU_DESC);
MODULE_VERSION(KSUDOKU_VERSION);
2020-03-31 18:57:03 +01:00
MODULE_LICENSE("GPL");
module_init(ksudoku_init);
module_exit(ksudoku_exit);