2020-03-31 21:29:50 +01:00
|
|
|
#ifndef _KSUDOKU_H_
|
|
|
|
#define _KSUDOKU_H_
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
|
2020-03-31 22:08:11 +01:00
|
|
|
#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);
|
2020-03-31 21:29:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
struct matrix_attribute {
|
|
|
|
struct attribute attr;
|
2020-03-31 22:08:11 +01:00
|
|
|
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
|
|
|
|
char *buf);
|
2020-03-31 21:29:50 +01:00
|
|
|
ssize_t (*store)(void);
|
|
|
|
bool value;
|
|
|
|
};
|
|
|
|
|
2020-03-31 22:08:11 +01:00
|
|
|
/*
|
|
|
|
* 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;
|
2020-03-31 21:29:50 +01:00
|
|
|
char matrix[81];
|
2020-03-31 22:08:11 +01:00
|
|
|
|
|
|
|
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;
|
2020-03-31 21:29:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
2020-03-31 22:08:11 +01:00
|
|
|
extern int sudoku_create_file(struct sudoku *s,
|
|
|
|
const struct matrix_attribute *attr)
|
2020-03-31 21:29:50 +01:00
|
|
|
#endif
|