ksudoku/ksudoku.h

61 lines
1.8 KiB
C
Raw Normal View History

#ifndef _KSUDOKU_H_
#define _KSUDOKU_H_
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sysfs.h>
#define to_sudoku(obj) container_of(obj, struct sudoku, kobj)
#define to_sudoku_attr(_attr) container_of(_attr, struct sudoku_attribute, attr)
struct sudoku;
static ssize_t is_valid_show(struct kobject *kobj, struct attribute *attr,
char *buf)
static ssize_t is_valid_store(void);
static ssize_t is_solved_show(struct kobject *kobj, struct attribute *attr,
char *buf);
static ssize_t is_solved_store(void);
struct matrix_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
ssize_t (*store)(void);
bool value;
};
/*
* The type of sudoku, "struct sudoku" is embedded in. A class
* or bus can only contain one sudoku type.
* This identifies the sudoku type and carries type-specific
* information, equivalent to the kobj_type of a kobject.
* Since we have only one type it always will be the same button
* we're designing a subsystem so we have to make sysfs happy.
* If "name" is specified, the uevent will contain it in
* the DEVTYPE variable.
*/
struct sudoku_type {
const char *name;
char matrix[81];
const struct attribute_group **groups;
int (*uevent)(struct sudoku *s, struct kobj_uevent_env *env);
char *(*devnode)(struct sudoku *s, umode_t *mode,
kuid_t *uid, kgid_t *gid);
void (*release)(struct sudoku *s);
const struct sysfs_ops *sysfs_ops;
};
#define MATRIX_ATTR_RO(_name) \
struct matrix_attribute matrix_##_name = __ATTR_RO(_name)
#define MATRIX_ATTR_WO(_name) \
struct matrix_attribute matrix_##_name = __ATTR_WO(_name)
extern int sudoku_create_file(struct sudoku *s,
const struct matrix_attribute *attr)
#endif