int target = -1; module_param(target, int, 0); MODULE_PARM_DESC(target, "PID du processus a monitorer"); /******************************************************************************* * Global ******************************************************************************/ /* initialisation de la kattr */ static ssize_t taskmonitor_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf); static ssize_t taskmonitor_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count); struct kobj_attribute taskmonitor_kattr = __ATTR_RW(taskmonitor); /* struct du processus à monitorer */ struct task_monitor { struct pid* target_pid; /* struct pid du target à monitorer */ struct task_struct* target_task; /* task_struct du target à monitorer */ struct list_head list; /* tête de liste de samples */ int s_count; /* compteur de samples */ struct mutex lock; /* verrou d'acces a la liste samples */ }; struct task_monitor* tm = NULL; static struct task_struct *monitor_thread = NULL; /* buffer de stockage des statistiques */ struct task_sample { struct list_head list;
char *buf) { return scnprintf(buf, PAGE_SIZE, "%i\n", CXL_API_VERSION); } static ssize_t api_version_compatible_show(struct device *device, struct device_attribute *attr, char *buf) { return scnprintf(buf, PAGE_SIZE, "%i\n", CXL_API_VERSION_COMPATIBLE); } static struct device_attribute afu_attrs[] = { __ATTR_RO(mmio_size), __ATTR_RO(irqs_min), __ATTR_RW(irqs_max), __ATTR_RO(modes_supported), __ATTR_RW(mode), __ATTR_RW(prefault_mode), __ATTR_RO(api_version), __ATTR_RO(api_version_compatible), __ATTR(reset, S_IWUSR, NULL, reset_store_afu), }; int cxl_sysfs_adapter_add(struct cxl *adapter) { int i, rc; for (i = 0; i < ARRAY_SIZE(adapter_attrs); i++) {
} #endif *((uint32_t *)buffer) = ALS_MIN_DELAY; return sizeof(uint32_t); } #ifdef CONFIG_STK_SYSFS_DBG static struct kobj_attribute help_attribute = (struct kobj_attribute)__ATTR_RO(help); static struct kobj_attribute driver_version_attribute = (struct kobj_attribute)__ATTR_RO(driver_version); #endif static struct kobj_attribute lux_range_attribute = (struct kobj_attribute)__ATTR_RO(lux_range); static struct kobj_attribute lux_attribute = (struct kobj_attribute)__ATTR_RW(lux); static struct kobj_attribute als_enable_attribute = (struct kobj_attribute)__ATTR_RW(als_enable); static struct kobj_attribute als_lux_res_attribute = (struct kobj_attribute)__ATTR_RO(lux_res); static struct bin_attribute als_lux_range_bin_attribute = __ATTR_BIN_RO(lux_range_bin, als_lux_range_read, sizeof(uint32_t)); static struct bin_attribute als_lux_bin_attribute = __ATTR_BIN_RO(lux_bin, lux_bin_read, sizeof(uint32_t)); static struct bin_attribute als_lux_res_bin_attribute = __ATTR_BIN_RO(lux_resolution_bin, als_lux_resolution_read, sizeof(uint32_t)); static struct bin_attribute als_enable_bin_attribute = __ATTR_BIN_RW(als_enable_bin, als_enable_read, als_enable_write, sizeof(uint8_t));
#define amba_attr(name,fmt,arg...) \ amba_attr_func(name,fmt,arg) \ static DEVICE_ATTR(name, S_IRUGO, name##_show, NULL) amba_attr_func(id, "%08x\n", dev->periphid); amba_attr(irq0, "%u\n", dev->irq[0]); amba_attr(irq1, "%u\n", dev->irq[1]); amba_attr_func(resource, "\t%016llx\t%016llx\t%016lx\n", (unsigned long long)dev->res.start, (unsigned long long)dev->res.end, dev->res.flags); static struct device_attribute amba_dev_attrs[] = { __ATTR_RO(id), __ATTR_RO(resource), __ATTR_RW(driver_override), __ATTR_NULL, }; #ifdef CONFIG_PM /* * Hooks to provide runtime PM of the pclk (bus clock). It is safe to * enable/disable the bus clock at runtime PM suspend/resume as this * does not result in loss of context. */ static int amba_pm_runtime_suspend(struct device *dev) { struct amba_device *pcdev = to_amba_device(dev); int ret = pm_generic_runtime_suspend(dev); if (ret == 0 && dev->driver) {
static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { struct msg_group_t *group = spk_find_msg_group(attr->attr.name); if (WARN_ON(!group)) return -EINVAL; return message_store_helper(buf, count, group); } /* * Declare the attributes. */ static struct kobj_attribute keymap_attribute = __ATTR_RW(keymap); static struct kobj_attribute silent_attribute = __ATTR_WO(silent); static struct kobj_attribute synth_attribute = __ATTR_RW(synth); static struct kobj_attribute synth_direct_attribute = __ATTR_WO(synth_direct); static struct kobj_attribute version_attribute = __ATTR_RO(version); static struct kobj_attribute delimiters_attribute = __ATTR(delimiters, 0644, punc_show, punc_store); static struct kobj_attribute ex_num_attribute = __ATTR(ex_num, 0644, punc_show, punc_store); static struct kobj_attribute punc_all_attribute = __ATTR(punc_all, 0644, punc_show, punc_store);
#include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/string.h> MODULE_DESCRIPTION("Module \"hellosysfs\" pour noyau linux"); MODULE_AUTHOR("Ilyas Toumlilt, M2 SAR, UPMC"); MODULE_LICENSE("GPL"); static ssize_t hellosysfs_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf); static ssize_t hellosysfs_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count); struct kobj_attribute hellosysfs_kattr = __ATTR_RW(hellosysfs); /* Le buffer fait PAGE_SIZE octets, mais ici j'estime que 128 octets me suffisent. */ #define BUFF_SIZE 128 #define DEFAULT_STR "Hello sysfs !\n" char hellosysfs_buff[BUFF_SIZE]; static int taskmonitor_init(void) { /* initialisation du buffer */ memset(hellosysfs_buff, 0, BUFF_SIZE); sprintf(hellosysfs_buff, "%s", DEFAULT_STR); if(unlikely(sysfs_create_file(kernel_kobj, &(hellosysfs_kattr.attr)))){
return 0; } static ssize_t caches_store(struct kobject *kobj, const char *buffer, size_t size) { char *arg; if ((arg = _chkcmd(buffer, "add")) != NULL) ssd_register(arg); else if ((arg = _chkcmd(buffer, "rm")) != NULL) ssd_unregister(arg); else ERR("Unknown kobject store to %s\n", kobject_name(kobj)); return size; } static struct ctl_attribute ctl_attr_cache = __ATTR_RW(caches); static ssize_t targets_show(struct kobject *kobj, char *buffer) { return 0; } static ssize_t targets_store(struct kobject *kobj, const char *buffer, size_t size) { char *arg; if ((arg = _chkcmd(buffer, "add")) != NULL) hdd_register(arg); else if ((arg = _chkcmd(buffer, "rm")) != NULL) hdd_unregister(arg); else ERR("Unknown kobject store to %s\n", kobject_name(kobj));
} /* PGGS register show functions */ static PGGS0_SHOW(0); static PGGS0_SHOW(1); static PGGS0_SHOW(2); static PGGS0_SHOW(3); /* PGGS register store functions */ static PGGS0_STORE(0); static PGGS0_STORE(1); static PGGS0_STORE(2); static PGGS0_STORE(3); /* GGS register attributes */ static struct kobj_attribute zynqmp_attr_ggs0 = __ATTR_RW(ggs0); static struct kobj_attribute zynqmp_attr_ggs1 = __ATTR_RW(ggs1); static struct kobj_attribute zynqmp_attr_ggs2 = __ATTR_RW(ggs2); static struct kobj_attribute zynqmp_attr_ggs3 = __ATTR_RW(ggs3); /* PGGS register attributes */ static struct kobj_attribute zynqmp_attr_pggs0 = __ATTR_RW(pggs0); static struct kobj_attribute zynqmp_attr_pggs1 = __ATTR_RW(pggs1); static struct kobj_attribute zynqmp_attr_pggs2 = __ATTR_RW(pggs2); static struct kobj_attribute zynqmp_attr_pggs3 = __ATTR_RW(pggs3); static struct attribute *attrs[] = { &zynqmp_attr_ggs0.attr, &zynqmp_attr_ggs1.attr, &zynqmp_attr_ggs2.attr, &zynqmp_attr_ggs3.attr,
static ssize_t enable_otg_show(struct kobject * kobj, struct kobj_attribute * attr, char * buf) { return sprintf(buf,"%d\n",(pDrvData->active&0x2)?1:0); } static ssize_t enable_otg_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t len) { uint32_t value = simple_strtoul(buf, NULL, 10); RT945x_enable_otg(value); return len; } static struct kobj_attribute reg0x00_attribute = (struct kobj_attribute)__ATTR_RW(reg0x00); static struct kobj_attribute reg0x01_attribute = (struct kobj_attribute)__ATTR_RW(reg0x01); static struct kobj_attribute reg0x02_attribute = (struct kobj_attribute)__ATTR_RW(reg0x02); static struct kobj_attribute reg0x03_attribute = (struct kobj_attribute)__ATTR_RO(reg0x03); static struct kobj_attribute reg0x04_attribute = (struct kobj_attribute)__ATTR_RW(reg0x04); static struct kobj_attribute reg0x05_attribute = (struct kobj_attribute)__ATTR_RO(reg0x05); static struct kobj_attribute reg0x06_attribute = (struct kobj_attribute)__ATTR_RO(reg0x06); static struct kobj_attribute model_name_attribute = (struct kobj_attribute)__ATTR_RO(model_name); static struct kobj_attribute status_attribute = (struct kobj_attribute)__ATTR_RO(status); static struct kobj_attribute chip_id_attribute = (struct kobj_attribute)__ATTR_RO(chip_id); static struct kobj_attribute bmfs_attribute = (struct kobj_attribute)__ATTR_RO(bmfs); static struct kobj_attribute cmfs_attribute = (struct kobj_attribute)__ATTR_RO(cmfs); static struct kobj_attribute enable_charge_attribute = (struct kobj_attribute)__ATTR_RW(enable_charge); static struct kobj_attribute enable_otg_attribute = (struct kobj_attribute)__ATTR_RW(enable_otg); static struct attribute* rt9450_dbg_attrs [] =
mutex_lock(&klp_mutex); patch = container_of(kobj, struct klp_patch, kobj); if (patch != klp_transition_patch) { mutex_unlock(&klp_mutex); return -EINVAL; } klp_force_transition(); mutex_unlock(&klp_mutex); return count; } static struct kobj_attribute enabled_kobj_attr = __ATTR_RW(enabled); static struct kobj_attribute transition_kobj_attr = __ATTR_RO(transition); static struct kobj_attribute signal_kobj_attr = __ATTR_WO(signal); static struct kobj_attribute force_kobj_attr = __ATTR_WO(force); static struct attribute *klp_patch_attrs[] = { &enabled_kobj_attr.attr, &transition_kobj_attr.attr, &signal_kobj_attr.attr, &force_kobj_attr.attr, NULL }; static void klp_kobj_release_patch(struct kobject *kobj) { struct klp_patch *patch;
static ssize_t icrmask_show(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t icrmask_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t loadinfo_show(struct device *dev, struct device_attribute *attr, char *buf); #define __ATTR_RW(_name, _mode) { \ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \ .show = _name##_show, \ .store = _name##_store, \ } static struct device_attribute dev_attr_ifver = __ATTR_RO(ifver); static struct device_attribute dev_attr_cpustat = __ATTR_RO(cpustat); static struct device_attribute dev_attr_icrmask = __ATTR_RW(icrmask, 0644); static struct device_attribute dev_attr_loadinfo = __ATTR_RO(loadinfo); /* * misc interactive mailbox command operations */ static struct misc_mb_wait_struct { struct mutex lock; wait_queue_head_t wait_q; u8 cmd_h; u8 cmd_l; u16 *retvp; } misc_mb_wait = { .lock = __MUTEX_INITIALIZER(misc_mb_wait.lock), .wait_q = __WAIT_QUEUE_HEAD_INITIALIZER(misc_mb_wait.wait_q), };