/* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform * read function right away to populate the file system. If not * then the pstore mount code will call us later to fill out * the file system. * * Register with kmsg_dump to save last part of console log on panic. */ int pstore_register(struct pstore_info *psi) { struct module *owner = psi->owner; spin_lock(&pstore_lock); if (psinfo) { spin_unlock(&pstore_lock); return -EBUSY; } if (backend && strcmp(backend, psi->name)) { spin_unlock(&pstore_lock); return -EINVAL; } psinfo = psi; mutex_init(&psinfo->read_mutex); spin_unlock(&pstore_lock); if (owner && !try_module_get(owner)) { psinfo = NULL; return -EINVAL; } if (pstore_is_mounted()) pstore_get_records(0); kmsg_dump_register(&pstore_dumper); pstore_timer.expires = jiffies + PSTORE_INTERVAL; add_timer(&pstore_timer); return 0; }
/* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform * read function right away to populate the file system. If not * then the pstore mount code will call us later to fill out * the file system. * * Register with kmsg_dump to save last part of console log on panic. */ int pstore_register(struct pstore_info *psi) { struct module *owner = psi->owner; spin_lock(&pstore_lock); if (psinfo) { spin_unlock(&pstore_lock); return -EBUSY; } if (backend && strcmp(backend, psi->name)) { spin_unlock(&pstore_lock); return -EINVAL; } psinfo = psi; spin_unlock(&pstore_lock); if (owner && !try_module_get(owner)) { psinfo = NULL; return -EINVAL; } if (pstore_is_mounted()) pstore_get_records(); kmsg_dump_register(&pstore_dumper); return 0; }
/* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform * read function right away to populate the file system. If not * then the pstore mount code will call us later to fill out * the file system. */ int pstore_register(struct pstore_info *psi) { struct module *owner = psi->owner; if (backend && strcmp(backend, psi->name)) return -EPERM; spin_lock(&pstore_lock); if (psinfo) { spin_unlock(&pstore_lock); return -EBUSY; } if (!psi->write) psi->write = pstore_write_compat; if (!psi->write_buf_user) psi->write_buf_user = pstore_write_buf_user_compat; psinfo = psi; mutex_init(&psinfo->read_mutex); spin_unlock(&pstore_lock); if (owner && !try_module_get(owner)) { psinfo = NULL; return -EINVAL; } allocate_buf_for_compression(); if (pstore_is_mounted()) pstore_get_records(0); if (psi->flags & PSTORE_FLAGS_DMESG) pstore_register_kmsg(); if (psi->flags & PSTORE_FLAGS_CONSOLE) pstore_register_console(); if (psi->flags & PSTORE_FLAGS_FTRACE) pstore_register_ftrace(); if (psi->flags & PSTORE_FLAGS_PMSG) pstore_register_pmsg(); if (pstore_update_ms >= 0) { pstore_timer.expires = jiffies + msecs_to_jiffies(pstore_update_ms); add_timer(&pstore_timer); } /* * Update the module parameter backend, so it is visible * through /sys/module/pstore/parameters/backend */ backend = psi->name; module_put(owner); pr_info("Registered %s as persistent store backend\n", psi->name); return 0; }
/* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform * read function right away to populate the file system. If not * then the pstore mount code will call us later to fill out * the file system. * * Register with kmsg_dump to save last part of console log on panic. */ int pstore_register(struct pstore_info *psi) { struct module *owner = psi->owner; spin_lock(&pstore_lock); if (psinfo) { spin_unlock(&pstore_lock); return -EBUSY; } if (backend && strcmp(backend, psi->name)) { spin_unlock(&pstore_lock); return -EINVAL; } if (!psi->write) psi->write = pstore_write_compat; psinfo = psi; mutex_init(&psinfo->read_mutex); spin_unlock(&pstore_lock); if (owner && !try_module_get(owner)) { psinfo = NULL; return -EINVAL; } if (pstore_is_mounted()) pstore_get_records(0); kmsg_dump_register(&pstore_dumper); pstore_register_console(); pstore_register_ftrace(); pstore_register_pmsg(); if (pstore_update_ms >= 0) { pstore_timer.expires = jiffies + msecs_to_jiffies(pstore_update_ms); add_timer(&pstore_timer); } pr_info("psi registered\n"); return 0; }
/* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform * read function right away to populate the file system. If not * then the pstore mount code will call us later to fill out * the file system. * * Register with kmsg_dump to save last part of console log on panic. */ int pstore_register(struct pstore_info *psi) { if (backend && strcmp(backend, psi->name)) return -EPERM; spin_lock(&pstore_lock); if (psinfo) { spin_unlock(&pstore_lock); return -EBUSY; } if (!psi->write) psi->write = pstore_write_compat; psinfo = psi; mutex_init(&psinfo->read_mutex); spin_unlock(&pstore_lock); pstore_get_records(0); pr_info("Registered %s as persistent store backend\n", psi->name); return 0; }
static void pstore_dowork(struct work_struct *work) { pstore_get_records(1); }
/* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform * read function right away to populate the file system. If not * then the pstore mount code will call us later to fill out * the file system. */ int pstore_register(struct pstore_info *psi) { struct module *owner = psi->owner; if (backend && strcmp(backend, psi->name)) { pr_warn("ignoring unexpected backend '%s'\n", psi->name); return -EPERM; } /* Sanity check flags. */ if (!psi->flags) { pr_warn("backend '%s' must support at least one frontend\n", psi->name); return -EINVAL; } /* Check for required functions. */ if (!psi->read || !psi->write) { pr_warn("backend '%s' must implement read() and write()\n", psi->name); return -EINVAL; } spin_lock(&pstore_lock); if (psinfo) { pr_warn("backend '%s' already loaded: ignoring '%s'\n", psinfo->name, psi->name); spin_unlock(&pstore_lock); return -EBUSY; } if (!psi->write_user) psi->write_user = pstore_write_user_compat; psinfo = psi; mutex_init(&psinfo->read_mutex); sema_init(&psinfo->buf_lock, 1); spin_unlock(&pstore_lock); if (owner && !try_module_get(owner)) { psinfo = NULL; return -EINVAL; } allocate_buf_for_compression(); if (pstore_is_mounted()) pstore_get_records(0); if (psi->flags & PSTORE_FLAGS_DMESG) pstore_register_kmsg(); if (psi->flags & PSTORE_FLAGS_CONSOLE) pstore_register_console(); if (psi->flags & PSTORE_FLAGS_FTRACE) pstore_register_ftrace(); if (psi->flags & PSTORE_FLAGS_PMSG) pstore_register_pmsg(); /* Start watching for new records, if desired. */ if (pstore_update_ms >= 0) { pstore_timer.expires = jiffies + msecs_to_jiffies(pstore_update_ms); add_timer(&pstore_timer); } /* * Update the module parameter backend, so it is visible * through /sys/module/pstore/parameters/backend */ backend = psi->name; pr_info("Registered %s as persistent store backend\n", psi->name); module_put(owner); return 0; }