sysfs: add snooping ops
This commit is contained in:
@@ -32,6 +32,29 @@ struct sysfs_handle {
|
||||
};
|
||||
typedef struct sysfs_handle sysfs_handle_t;
|
||||
|
||||
struct sysfs_bitmap_param {
|
||||
int nbits;
|
||||
int padding;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
#define SYSFS_SPECIAL_OPS_MIN ((void *)1)
|
||||
#define SYSFS_SPECIAL_OPS_MAX ((void *)1000)
|
||||
|
||||
#define SYSFS_SNOOPING_OPS_d32 ((void *)1)
|
||||
#define SYSFS_SNOOPING_OPS_d64 ((void *)2)
|
||||
#define SYSFS_SNOOPING_OPS_u32 ((void *)3)
|
||||
#define SYSFS_SNOOPING_OPS_u64 ((void *)4)
|
||||
#define SYSFS_SNOOPING_OPS_s ((void *)5)
|
||||
#define SYSFS_SNOOPING_OPS_pbl ((void *)6)
|
||||
#define SYSFS_SNOOPING_OPS_pb ((void *)7)
|
||||
#define SYSFS_SNOOPING_OPS_u32K ((void *)8)
|
||||
|
||||
static inline int is_special_sysfs_ops(void *ops)
|
||||
{
|
||||
return (((long)SYSFS_SPECIAL_OPS_MIN <= (long)ops)
|
||||
&& ((long)ops <= (long)SYSFS_SPECIAL_OPS_MAX));
|
||||
}
|
||||
|
||||
extern int sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
|
||||
const char *fmt, ...);
|
||||
|
||||
@@ -25,6 +25,18 @@ struct sysfs_req_create_param {
|
||||
int busy;
|
||||
}; /* struct sysfs_req_create_param */
|
||||
|
||||
#define SYSFS_SPECIAL_OPS_MIN ((void *)1)
|
||||
#define SYSFS_SPECIAL_OPS_MAX ((void *)1000)
|
||||
|
||||
#define SYSFS_SNOOPING_OPS_d32 ((void *)1)
|
||||
#define SYSFS_SNOOPING_OPS_d64 ((void *)2)
|
||||
#define SYSFS_SNOOPING_OPS_u32 ((void *)3)
|
||||
#define SYSFS_SNOOPING_OPS_u64 ((void *)4)
|
||||
#define SYSFS_SNOOPING_OPS_s ((void *)5)
|
||||
#define SYSFS_SNOOPING_OPS_pbl ((void *)6)
|
||||
#define SYSFS_SNOOPING_OPS_pb ((void *)7)
|
||||
#define SYSFS_SNOOPING_OPS_u32K ((void *)8)
|
||||
|
||||
struct sysfs_req_mkdir_param {
|
||||
int error;
|
||||
int padding;
|
||||
|
||||
@@ -30,6 +30,37 @@
|
||||
static size_t sysfs_data_bufsize;
|
||||
static void *sysfs_data_buf;
|
||||
|
||||
static int setup_special_create(struct sysfs_req_create_param *param, struct sysfs_bitmap_param *pbp)
|
||||
{
|
||||
void *cinstance = (void *)param->client_instance;
|
||||
|
||||
switch (param->client_ops) {
|
||||
case (long)SYSFS_SNOOPING_OPS_d32:
|
||||
case (long)SYSFS_SNOOPING_OPS_d64:
|
||||
case (long)SYSFS_SNOOPING_OPS_u32:
|
||||
case (long)SYSFS_SNOOPING_OPS_u64:
|
||||
case (long)SYSFS_SNOOPING_OPS_u32K:
|
||||
param->client_instance = virt_to_phys(cinstance);
|
||||
return 0;
|
||||
|
||||
case (long)SYSFS_SNOOPING_OPS_s:
|
||||
pbp->nbits = 8 * (strlen(cinstance) + 1);
|
||||
pbp->ptr = (void *)virt_to_phys(cinstance);
|
||||
param->client_instance = virt_to_phys(pbp);
|
||||
return 0;
|
||||
|
||||
case (long)SYSFS_SNOOPING_OPS_pbl:
|
||||
case (long)SYSFS_SNOOPING_OPS_pb:
|
||||
*pbp = *(struct sysfs_bitmap_param *)cinstance;
|
||||
pbp->ptr = (void *)virt_to_phys(pbp->ptr);
|
||||
param->client_instance = virt_to_phys(pbp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ekprintf("setup_special_create:unknown ops %#lx\n", param->client_ops);
|
||||
return -EINVAL;
|
||||
} /* setup_special_create() */
|
||||
|
||||
int
|
||||
sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
|
||||
const char *fmt, ...)
|
||||
@@ -39,6 +70,7 @@ sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
|
||||
ssize_t n;
|
||||
struct sysfs_req_create_param *param = NULL;
|
||||
struct ikc_scd_packet packet;
|
||||
struct sysfs_bitmap_param asbp;
|
||||
|
||||
dkprintf("sysfs_createf(%p,%p,%#o,%s,...)\n",
|
||||
ops, instance, mode, fmt);
|
||||
@@ -70,6 +102,14 @@ sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (is_special_sysfs_ops(ops)) {
|
||||
error = setup_special_create(param, &asbp);
|
||||
if (error) {
|
||||
ekprintf("sysfs_createf:setup_special_create failed. %d\n", error);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
packet.msg = SCD_MSG_SYSFS_REQ_CREATE;
|
||||
packet.sysfs_arg1 = virt_to_phys(param);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user