mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
s390/debug: adjust coding style
The debug feature code hasn't been touched in ages and the code also looks like this. Therefore clean up the code so it looks a bit more like current coding style. There is no functional change - actually I made also sure that the generated code with performance_defconfig is identical. A diff of old vs new with "objdump -d" is empty. The code is still not checkpatch clean, but that was not the goal. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
committed by
Martin Schwidefsky
parent
0bb6bba5fb
commit
496da0d706
@@ -113,34 +113,36 @@ static inline bool debug_level_enabled(debug_info_t* id, int level)
|
||||
return level <= id->level;
|
||||
}
|
||||
|
||||
static inline debug_entry_t*
|
||||
debug_event(debug_info_t* id, int level, void* data, int length)
|
||||
static inline debug_entry_t *debug_event(debug_info_t *id, int level,
|
||||
void *data, int length)
|
||||
{
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
return debug_event_common(id, level, data, length);
|
||||
}
|
||||
|
||||
static inline debug_entry_t*
|
||||
debug_int_event(debug_info_t* id, int level, unsigned int tag)
|
||||
static inline debug_entry_t *debug_int_event(debug_info_t *id, int level,
|
||||
unsigned int tag)
|
||||
{
|
||||
unsigned int t = tag;
|
||||
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
return debug_event_common(id, level, &t, sizeof(unsigned int));
|
||||
}
|
||||
|
||||
static inline debug_entry_t *
|
||||
debug_long_event (debug_info_t* id, int level, unsigned long tag)
|
||||
static inline debug_entry_t *debug_long_event(debug_info_t *id, int level,
|
||||
unsigned long tag)
|
||||
{
|
||||
unsigned long t = tag;
|
||||
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
return debug_event_common(id, level, &t, sizeof(unsigned long));
|
||||
}
|
||||
|
||||
static inline debug_entry_t*
|
||||
debug_text_event(debug_info_t* id, int level, const char* txt)
|
||||
static inline debug_entry_t *debug_text_event(debug_info_t *id, int level,
|
||||
const char *txt)
|
||||
{
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
@@ -160,6 +162,7 @@ __debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
|
||||
debug_entry_t *__ret; \
|
||||
debug_info_t *__id = _id; \
|
||||
int __level = _level; \
|
||||
\
|
||||
if ((!__id) || (__level > __id->level)) \
|
||||
__ret = NULL; \
|
||||
else \
|
||||
@@ -168,34 +171,36 @@ __debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
|
||||
__ret; \
|
||||
})
|
||||
|
||||
static inline debug_entry_t*
|
||||
debug_exception(debug_info_t* id, int level, void* data, int length)
|
||||
static inline debug_entry_t *debug_exception(debug_info_t *id, int level,
|
||||
void *data, int length)
|
||||
{
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
return debug_exception_common(id, level, data, length);
|
||||
}
|
||||
|
||||
static inline debug_entry_t*
|
||||
debug_int_exception(debug_info_t* id, int level, unsigned int tag)
|
||||
static inline debug_entry_t *debug_int_exception(debug_info_t *id, int level,
|
||||
unsigned int tag)
|
||||
{
|
||||
unsigned int t = tag;
|
||||
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
return debug_exception_common(id, level, &t, sizeof(unsigned int));
|
||||
}
|
||||
|
||||
static inline debug_entry_t *
|
||||
debug_long_exception (debug_info_t* id, int level, unsigned long tag)
|
||||
static inline debug_entry_t *debug_long_exception (debug_info_t *id, int level,
|
||||
unsigned long tag)
|
||||
{
|
||||
unsigned long t = tag;
|
||||
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
return debug_exception_common(id, level, &t, sizeof(unsigned long));
|
||||
}
|
||||
|
||||
static inline debug_entry_t*
|
||||
debug_text_exception(debug_info_t* id, int level, const char* txt)
|
||||
static inline debug_entry_t *debug_text_exception(debug_info_t *id, int level,
|
||||
const char *txt)
|
||||
{
|
||||
if ((!id) || (level > id->level) || (id->pages_per_area == 0))
|
||||
return NULL;
|
||||
@@ -215,6 +220,7 @@ __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
|
||||
debug_entry_t *__ret; \
|
||||
debug_info_t *__id = _id; \
|
||||
int __level = _level; \
|
||||
\
|
||||
if ((!__id) || (__level > __id->level)) \
|
||||
__ret = NULL; \
|
||||
else \
|
||||
|
@@ -50,8 +50,7 @@ typedef struct file_private_info {
|
||||
struct debug_view *view; /* used view of debug info */
|
||||
} file_private_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
char *string;
|
||||
/*
|
||||
* This assumes that all args are converted into longs
|
||||
@@ -62,7 +61,6 @@ typedef struct
|
||||
long args[0];
|
||||
} debug_sprintf_entry_t;
|
||||
|
||||
|
||||
/* internal function prototyes */
|
||||
|
||||
static int debug_init(void);
|
||||
@@ -164,8 +162,8 @@ static unsigned int __used debug_feature_version = __DEBUG_FEATURE_VERSION;
|
||||
|
||||
/* static globals */
|
||||
|
||||
static debug_info_t *debug_area_first = NULL;
|
||||
static debug_info_t *debug_area_last = NULL;
|
||||
static debug_info_t *debug_area_first;
|
||||
static debug_info_t *debug_area_last;
|
||||
static DEFINE_MUTEX(debug_mutex);
|
||||
|
||||
static int initialized;
|
||||
@@ -190,29 +188,23 @@ static struct dentry *debug_debugfs_root_entry;
|
||||
* areas[areanumber][pagenumber][pageoffset]
|
||||
*/
|
||||
|
||||
static debug_entry_t***
|
||||
debug_areas_alloc(int pages_per_area, int nr_areas)
|
||||
static debug_entry_t ***debug_areas_alloc(int pages_per_area, int nr_areas)
|
||||
{
|
||||
debug_entry_t ***areas;
|
||||
int i, j;
|
||||
|
||||
areas = kmalloc(nr_areas *
|
||||
sizeof(debug_entry_t**),
|
||||
GFP_KERNEL);
|
||||
areas = kmalloc(nr_areas * sizeof(debug_entry_t **), GFP_KERNEL);
|
||||
if (!areas)
|
||||
goto fail_malloc_areas;
|
||||
for (i = 0; i < nr_areas; i++) {
|
||||
areas[i] = kmalloc(pages_per_area *
|
||||
sizeof(debug_entry_t*),GFP_KERNEL);
|
||||
if (!areas[i]) {
|
||||
areas[i] = kmalloc(pages_per_area * sizeof(debug_entry_t *), GFP_KERNEL);
|
||||
if (!areas[i])
|
||||
goto fail_malloc_areas2;
|
||||
}
|
||||
for (j = 0; j < pages_per_area; j++) {
|
||||
areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!areas[i][j]) {
|
||||
for(j--; j >=0 ; j--) {
|
||||
for (j--; j >= 0 ; j--)
|
||||
kfree(areas[i][j]);
|
||||
}
|
||||
kfree(areas[i]);
|
||||
goto fail_malloc_areas2;
|
||||
}
|
||||
@@ -222,31 +214,26 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
|
||||
|
||||
fail_malloc_areas2:
|
||||
for (i--; i >= 0; i--) {
|
||||
for(j=0; j < pages_per_area;j++){
|
||||
for (j = 0; j < pages_per_area; j++)
|
||||
kfree(areas[i][j]);
|
||||
}
|
||||
kfree(areas[i]);
|
||||
}
|
||||
kfree(areas);
|
||||
fail_malloc_areas:
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* debug_info_alloc
|
||||
* - alloc new debug-info
|
||||
*/
|
||||
|
||||
static debug_info_t*
|
||||
debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
|
||||
int buf_size, int level, int mode)
|
||||
static debug_info_t *debug_info_alloc(const char *name, int pages_per_area,
|
||||
int nr_areas, int buf_size, int level,
|
||||
int mode)
|
||||
{
|
||||
debug_info_t *rc;
|
||||
|
||||
/* alloc everything */
|
||||
|
||||
rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL);
|
||||
if (!rc)
|
||||
goto fail_malloc_rc;
|
||||
@@ -265,7 +252,6 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
|
||||
}
|
||||
|
||||
/* initialize members */
|
||||
|
||||
spin_lock_init(&rc->lock);
|
||||
rc->pages_per_area = pages_per_area;
|
||||
rc->nr_areas = nr_areas;
|
||||
@@ -275,8 +261,7 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
|
||||
rc->entry_size = sizeof(debug_entry_t) + buf_size;
|
||||
strlcpy(rc->name, name, sizeof(rc->name));
|
||||
memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *));
|
||||
memset(rc->debugfs_entries, 0 ,DEBUG_MAX_VIEWS *
|
||||
sizeof(struct dentry*));
|
||||
memset(rc->debugfs_entries, 0, DEBUG_MAX_VIEWS * sizeof(struct dentry *));
|
||||
refcount_set(&(rc->ref_count), 0);
|
||||
|
||||
return rc;
|
||||
@@ -295,18 +280,15 @@ fail_malloc_rc:
|
||||
* debug_areas_free
|
||||
* - free all debug areas
|
||||
*/
|
||||
|
||||
static void
|
||||
debug_areas_free(debug_info_t* db_info)
|
||||
static void debug_areas_free(debug_info_t *db_info)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (!db_info->areas)
|
||||
return;
|
||||
for (i = 0; i < db_info->nr_areas; i++) {
|
||||
for(j = 0; j < db_info->pages_per_area; j++) {
|
||||
for (j = 0; j < db_info->pages_per_area; j++)
|
||||
kfree(db_info->areas[i][j]);
|
||||
}
|
||||
kfree(db_info->areas[i]);
|
||||
}
|
||||
kfree(db_info->areas);
|
||||
@@ -317,9 +299,8 @@ debug_areas_free(debug_info_t* db_info)
|
||||
* debug_info_free
|
||||
* - free memory debug-info
|
||||
*/
|
||||
|
||||
static void
|
||||
debug_info_free(debug_info_t* db_info){
|
||||
static void debug_info_free(debug_info_t *db_info)
|
||||
{
|
||||
debug_areas_free(db_info);
|
||||
kfree(db_info->active_entries);
|
||||
kfree(db_info->active_pages);
|
||||
@@ -331,9 +312,8 @@ debug_info_free(debug_info_t* db_info){
|
||||
* - create new debug-info
|
||||
*/
|
||||
|
||||
static debug_info_t*
|
||||
debug_info_create(const char *name, int pages_per_area, int nr_areas,
|
||||
int buf_size, umode_t mode)
|
||||
static debug_info_t *debug_info_create(const char *name, int pages_per_area,
|
||||
int nr_areas, int buf_size, umode_t mode)
|
||||
{
|
||||
debug_info_t *rc;
|
||||
|
||||
@@ -370,13 +350,11 @@ out:
|
||||
* debug_info_copy
|
||||
* - copy debug-info
|
||||
*/
|
||||
|
||||
static debug_info_t*
|
||||
debug_info_copy(debug_info_t* in, int mode)
|
||||
static debug_info_t *debug_info_copy(debug_info_t *in, int mode)
|
||||
{
|
||||
int i,j;
|
||||
debug_info_t* rc;
|
||||
unsigned long flags;
|
||||
debug_info_t *rc;
|
||||
int i, j;
|
||||
|
||||
/* get a consistent copy of the debug areas */
|
||||
do {
|
||||
@@ -398,10 +376,9 @@ debug_info_copy(debug_info_t* in, int mode)
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < in->nr_areas; i++) {
|
||||
for(j = 0; j < in->pages_per_area; j++) {
|
||||
for (j = 0; j < in->pages_per_area; j++)
|
||||
memcpy(rc->areas[i][j], in->areas[i][j], PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
out:
|
||||
spin_unlock_irqrestore(&in->lock, flags);
|
||||
return rc;
|
||||
@@ -411,9 +388,7 @@ out:
|
||||
* debug_info_get
|
||||
* - increments reference count for debug-info
|
||||
*/
|
||||
|
||||
static void
|
||||
debug_info_get(debug_info_t * db_info)
|
||||
static void debug_info_get(debug_info_t *db_info)
|
||||
{
|
||||
if (db_info)
|
||||
refcount_inc(&db_info->ref_count);
|
||||
@@ -423,9 +398,7 @@ debug_info_get(debug_info_t * db_info)
|
||||
* debug_info_put:
|
||||
* - decreases reference count for debug-info and frees it if necessary
|
||||
*/
|
||||
|
||||
static void
|
||||
debug_info_put(debug_info_t *db_info)
|
||||
static void debug_info_put(debug_info_t *db_info)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -442,8 +415,10 @@ debug_info_put(debug_info_t *db_info)
|
||||
debug_area_first = db_info->next;
|
||||
if (db_info == debug_area_last)
|
||||
debug_area_last = db_info->prev;
|
||||
if(db_info->prev) db_info->prev->next = db_info->next;
|
||||
if(db_info->next) db_info->next->prev = db_info->prev;
|
||||
if (db_info->prev)
|
||||
db_info->prev->next = db_info->next;
|
||||
if (db_info->next)
|
||||
db_info->next->prev = db_info->prev;
|
||||
debug_info_free(db_info);
|
||||
}
|
||||
}
|
||||
@@ -452,14 +427,13 @@ debug_info_put(debug_info_t *db_info)
|
||||
* debug_format_entry:
|
||||
* - format one debug entry and return size of formated data
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_format_entry(file_private_info_t *p_info)
|
||||
static int debug_format_entry(file_private_info_t *p_info)
|
||||
{
|
||||
debug_info_t *id_snap = p_info->debug_info_snap;
|
||||
struct debug_view *view = p_info->view;
|
||||
debug_entry_t *act_entry;
|
||||
size_t len = 0;
|
||||
|
||||
if (p_info->act_entry == DEBUG_PROLOG_ENTRY) {
|
||||
/* print prolog */
|
||||
if (view->prolog_proc)
|
||||
@@ -487,9 +461,7 @@ out:
|
||||
* debug_next_entry:
|
||||
* - goto next entry in p_info
|
||||
*/
|
||||
|
||||
static inline int
|
||||
debug_next_entry(file_private_info_t *p_info)
|
||||
static inline int debug_next_entry(file_private_info_t *p_info)
|
||||
{
|
||||
debug_info_t *id;
|
||||
|
||||
@@ -524,9 +496,7 @@ out:
|
||||
* - called for user read()
|
||||
* - copies formated debug entries to the user buffer
|
||||
*/
|
||||
|
||||
static ssize_t
|
||||
debug_output(struct file *file, /* file descriptor */
|
||||
static ssize_t debug_output(struct file *file, /* file descriptor */
|
||||
char __user *user_buf, /* user buffer */
|
||||
size_t len, /* length of buffer */
|
||||
loff_t *offset) /* offset in the file */
|
||||
@@ -535,15 +505,15 @@ debug_output(struct file *file, /* file descriptor */
|
||||
size_t entry_offset;
|
||||
file_private_info_t *p_info;
|
||||
|
||||
p_info = ((file_private_info_t *) file->private_data);
|
||||
p_info = (file_private_info_t *) file->private_data;
|
||||
if (*offset != p_info->offset)
|
||||
return -EPIPE;
|
||||
if (p_info->act_area >= p_info->debug_info_snap->nr_areas)
|
||||
return 0;
|
||||
entry_offset = p_info->act_entry_offset;
|
||||
while (count < len) {
|
||||
int formatted_line_size;
|
||||
int formatted_line_residue;
|
||||
int formatted_line_size;
|
||||
int user_buf_residue;
|
||||
size_t copy_size;
|
||||
|
||||
@@ -576,22 +546,21 @@ out:
|
||||
* - called for user write()
|
||||
* - calls input function of view
|
||||
*/
|
||||
|
||||
static ssize_t
|
||||
debug_input(struct file *file, const char __user *user_buf, size_t length,
|
||||
loff_t *offset)
|
||||
static ssize_t debug_input(struct file *file, const char __user *user_buf,
|
||||
size_t length, loff_t *offset)
|
||||
{
|
||||
int rc = 0;
|
||||
file_private_info_t *p_info;
|
||||
int rc = 0;
|
||||
|
||||
mutex_lock(&debug_mutex);
|
||||
p_info = ((file_private_info_t *) file->private_data);
|
||||
if (p_info->view->input_proc)
|
||||
if (p_info->view->input_proc) {
|
||||
rc = p_info->view->input_proc(p_info->debug_info_org,
|
||||
p_info->view, file, user_buf,
|
||||
length, offset);
|
||||
else
|
||||
} else {
|
||||
rc = -EPERM;
|
||||
}
|
||||
mutex_unlock(&debug_mutex);
|
||||
return rc; /* number of input characters */
|
||||
}
|
||||
@@ -602,13 +571,11 @@ debug_input(struct file *file, const char __user *user_buf, size_t length,
|
||||
* - copies formated output to private_data area of the file
|
||||
* handle
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_open(struct inode *inode, struct file *file)
|
||||
static int debug_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int i, rc = 0;
|
||||
file_private_info_t *p_info;
|
||||
debug_info_t *debug_info, *debug_info_snapshot;
|
||||
file_private_info_t *p_info;
|
||||
int i, rc = 0;
|
||||
|
||||
mutex_lock(&debug_mutex);
|
||||
debug_info = file_inode(file)->i_private;
|
||||
@@ -616,11 +583,9 @@ debug_open(struct inode *inode, struct file *file)
|
||||
for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
|
||||
if (!debug_info->views[i])
|
||||
continue;
|
||||
else if (debug_info->debugfs_entries[i] ==
|
||||
file->f_path.dentry) {
|
||||
else if (debug_info->debugfs_entries[i] == file->f_path.dentry)
|
||||
goto found; /* found view ! */
|
||||
}
|
||||
}
|
||||
/* no entry found */
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
@@ -631,19 +596,16 @@ found:
|
||||
/* To copy all the areas is only needed, if we have a view which */
|
||||
/* formats the debug areas. */
|
||||
|
||||
if(!debug_info->views[i]->format_proc &&
|
||||
!debug_info->views[i]->header_proc){
|
||||
if (!debug_info->views[i]->format_proc && !debug_info->views[i]->header_proc)
|
||||
debug_info_snapshot = debug_info_copy(debug_info, NO_AREAS);
|
||||
} else {
|
||||
else
|
||||
debug_info_snapshot = debug_info_copy(debug_info, ALL_AREAS);
|
||||
}
|
||||
|
||||
if (!debug_info_snapshot) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
p_info = kmalloc(sizeof(file_private_info_t),
|
||||
GFP_KERNEL);
|
||||
p_info = kmalloc(sizeof(file_private_info_t), GFP_KERNEL);
|
||||
if (!p_info) {
|
||||
debug_info_free(debug_info_snapshot);
|
||||
rc = -ENOMEM;
|
||||
@@ -670,11 +632,10 @@ out:
|
||||
* - called for user close()
|
||||
* - deletes private_data area of the file handle
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_close(struct inode *inode, struct file *file)
|
||||
static int debug_close(struct inode *inode, struct file *file)
|
||||
{
|
||||
file_private_info_t *p_info;
|
||||
|
||||
p_info = (file_private_info_t *) file->private_data;
|
||||
if (p_info->debug_info_snap)
|
||||
debug_info_free(p_info->debug_info_snap);
|
||||
@@ -689,7 +650,6 @@ debug_close(struct inode *inode, struct file *file)
|
||||
* The mode parameter allows to specify access rights for the s390dbf files
|
||||
* - Returns handle for debug area
|
||||
*/
|
||||
|
||||
debug_info_t *debug_register_mode(const char *name, int pages_per_area,
|
||||
int nr_areas, int buf_size, umode_t mode,
|
||||
uid_t uid, gid_t gid)
|
||||
@@ -704,7 +664,6 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
|
||||
mutex_lock(&debug_mutex);
|
||||
|
||||
/* create new debug_info */
|
||||
|
||||
rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode);
|
||||
if (!rc)
|
||||
goto out;
|
||||
@@ -712,9 +671,8 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
|
||||
debug_register_view(rc, &debug_flush_view);
|
||||
debug_register_view(rc, &debug_pages_view);
|
||||
out:
|
||||
if (!rc){
|
||||
if (!rc)
|
||||
pr_err("Registering debug feature %s failed\n", name);
|
||||
}
|
||||
mutex_unlock(&debug_mutex);
|
||||
return rc;
|
||||
}
|
||||
@@ -725,7 +683,6 @@ EXPORT_SYMBOL(debug_register_mode);
|
||||
* - creates and initializes debug area for the caller
|
||||
* - returns handle for debug area
|
||||
*/
|
||||
|
||||
debug_info_t *debug_register(const char *name, int pages_per_area,
|
||||
int nr_areas, int buf_size)
|
||||
{
|
||||
@@ -738,18 +695,13 @@ EXPORT_SYMBOL(debug_register);
|
||||
* debug_unregister:
|
||||
* - give back debug area
|
||||
*/
|
||||
|
||||
void
|
||||
debug_unregister(debug_info_t * id)
|
||||
void debug_unregister(debug_info_t *id)
|
||||
{
|
||||
if (!id)
|
||||
goto out;
|
||||
return;
|
||||
mutex_lock(&debug_mutex);
|
||||
debug_info_put(id);
|
||||
mutex_unlock(&debug_mutex);
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
EXPORT_SYMBOL(debug_unregister);
|
||||
|
||||
@@ -757,11 +709,10 @@ EXPORT_SYMBOL(debug_unregister);
|
||||
* debug_set_size:
|
||||
* - set area size (number of pages) and number of areas
|
||||
*/
|
||||
static int
|
||||
debug_set_size(debug_info_t* id, int nr_areas, int pages_per_area)
|
||||
static int debug_set_size(debug_info_t *id, int nr_areas, int pages_per_area)
|
||||
{
|
||||
unsigned long flags;
|
||||
debug_entry_t ***new_areas;
|
||||
unsigned long flags;
|
||||
int rc = 0;
|
||||
|
||||
if (!id || (nr_areas <= 0) || (pages_per_area < 0))
|
||||
@@ -795,11 +746,10 @@ out:
|
||||
* debug_set_level:
|
||||
* - set actual debug level
|
||||
*/
|
||||
|
||||
void
|
||||
debug_set_level(debug_info_t* id, int new_level)
|
||||
void debug_set_level(debug_info_t *id, int new_level)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
if (!id)
|
||||
return;
|
||||
spin_lock_irqsave(&id->lock, flags);
|
||||
@@ -820,9 +770,7 @@ EXPORT_SYMBOL(debug_set_level);
|
||||
* proceed_active_entry:
|
||||
* - set active entry to next in the ring buffer
|
||||
*/
|
||||
|
||||
static inline void
|
||||
proceed_active_entry(debug_info_t * id)
|
||||
static inline void proceed_active_entry(debug_info_t *id)
|
||||
{
|
||||
if ((id->active_entries[id->active_area] += id->entry_size)
|
||||
> (PAGE_SIZE - id->entry_size)) {
|
||||
@@ -837,9 +785,7 @@ proceed_active_entry(debug_info_t * id)
|
||||
* proceed_active_area:
|
||||
* - set active area to next in the ring buffer
|
||||
*/
|
||||
|
||||
static inline void
|
||||
proceed_active_area(debug_info_t * id)
|
||||
static inline void proceed_active_area(debug_info_t *id)
|
||||
{
|
||||
id->active_area++;
|
||||
id->active_area = id->active_area % id->nr_areas;
|
||||
@@ -848,9 +794,7 @@ proceed_active_area(debug_info_t * id)
|
||||
/*
|
||||
* get_active_entry:
|
||||
*/
|
||||
|
||||
static inline debug_entry_t*
|
||||
get_active_entry(debug_info_t * id)
|
||||
static inline debug_entry_t *get_active_entry(debug_info_t *id)
|
||||
{
|
||||
return (debug_entry_t *) (((char *) id->areas[id->active_area]
|
||||
[id->active_pages[id->active_area]]) +
|
||||
@@ -862,9 +806,8 @@ get_active_entry(debug_info_t * id)
|
||||
* - set timestamp, caller address, cpu number etc.
|
||||
*/
|
||||
|
||||
static inline void
|
||||
debug_finish_entry(debug_info_t * id, debug_entry_t* active, int level,
|
||||
int exception)
|
||||
static inline void debug_finish_entry(debug_info_t *id, debug_entry_t *active,
|
||||
int level, int exception)
|
||||
{
|
||||
active->id.stck = get_tod_clock_fast() -
|
||||
*(unsigned long long *) &tod_clock_base[1];
|
||||
@@ -888,8 +831,7 @@ static int debug_active=1;
|
||||
* always allow read, allow write only if debug_stoppable is set or
|
||||
* if debug_active is already off
|
||||
*/
|
||||
static int
|
||||
s390dbf_procactive(struct ctl_table *table, int write,
|
||||
static int s390dbf_procactive(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
if (!write || debug_stoppable || !debug_active)
|
||||
@@ -898,7 +840,6 @@ s390dbf_procactive(struct ctl_table *table, int write,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static struct ctl_table s390dbf_table[] = {
|
||||
{
|
||||
.procname = "debug_stoppable",
|
||||
@@ -929,8 +870,7 @@ static struct ctl_table s390dbf_dir_table[] = {
|
||||
|
||||
static struct ctl_table_header *s390dbf_sysctl_header;
|
||||
|
||||
void
|
||||
debug_stop_all(void)
|
||||
void debug_stop_all(void)
|
||||
{
|
||||
if (debug_stoppable)
|
||||
debug_active = 0;
|
||||
@@ -946,20 +886,20 @@ void debug_set_critical(void)
|
||||
* debug_event_common:
|
||||
* - write debug entry with given size
|
||||
*/
|
||||
|
||||
debug_entry_t*
|
||||
debug_event_common(debug_info_t * id, int level, const void *buf, int len)
|
||||
debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf,
|
||||
int len)
|
||||
{
|
||||
unsigned long flags;
|
||||
debug_entry_t *active;
|
||||
unsigned long flags;
|
||||
|
||||
if (!debug_active || !id->areas)
|
||||
return NULL;
|
||||
if (debug_critical) {
|
||||
if (!spin_trylock_irqsave(&id->lock, flags))
|
||||
return NULL;
|
||||
} else
|
||||
} else {
|
||||
spin_lock_irqsave(&id->lock, flags);
|
||||
}
|
||||
active = get_active_entry(id);
|
||||
memset(DEBUG_DATA(active), 0, id->buf_size);
|
||||
memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
|
||||
@@ -974,20 +914,20 @@ EXPORT_SYMBOL(debug_event_common);
|
||||
* debug_exception_common:
|
||||
* - write debug entry with given size and switch to next debug area
|
||||
*/
|
||||
|
||||
debug_entry_t
|
||||
*debug_exception_common(debug_info_t * id, int level, const void *buf, int len)
|
||||
debug_entry_t *debug_exception_common(debug_info_t *id, int level,
|
||||
const void *buf, int len)
|
||||
{
|
||||
unsigned long flags;
|
||||
debug_entry_t *active;
|
||||
unsigned long flags;
|
||||
|
||||
if (!debug_active || !id->areas)
|
||||
return NULL;
|
||||
if (debug_critical) {
|
||||
if (!spin_trylock_irqsave(&id->lock, flags))
|
||||
return NULL;
|
||||
} else
|
||||
} else {
|
||||
spin_lock_irqsave(&id->lock, flags);
|
||||
}
|
||||
active = get_active_entry(id);
|
||||
memset(DEBUG_DATA(active), 0, id->buf_size);
|
||||
memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
|
||||
@@ -1001,9 +941,7 @@ EXPORT_SYMBOL(debug_exception_common);
|
||||
/*
|
||||
* counts arguments in format string for sprintf view
|
||||
*/
|
||||
|
||||
static inline int
|
||||
debug_count_numargs(char *string)
|
||||
static inline int debug_count_numargs(char *string)
|
||||
{
|
||||
int numargs = 0;
|
||||
|
||||
@@ -1011,21 +949,19 @@ debug_count_numargs(char *string)
|
||||
if (*string++ == '%')
|
||||
numargs++;
|
||||
}
|
||||
return(numargs);
|
||||
return numargs;
|
||||
}
|
||||
|
||||
/*
|
||||
* debug_sprintf_event:
|
||||
*/
|
||||
|
||||
debug_entry_t*
|
||||
__debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
|
||||
debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int numargs,idx;
|
||||
unsigned long flags;
|
||||
debug_sprintf_entry_t *curr_event;
|
||||
debug_entry_t *active;
|
||||
unsigned long flags;
|
||||
int numargs, idx;
|
||||
va_list ap;
|
||||
|
||||
if (!debug_active || !id->areas)
|
||||
return NULL;
|
||||
@@ -1034,8 +970,9 @@ __debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
|
||||
if (debug_critical) {
|
||||
if (!spin_trylock_irqsave(&id->lock, flags))
|
||||
return NULL;
|
||||
} else
|
||||
} else {
|
||||
spin_lock_irqsave(&id->lock, flags);
|
||||
}
|
||||
active = get_active_entry(id);
|
||||
curr_event = (debug_sprintf_entry_t *) DEBUG_DATA(active);
|
||||
va_start(ap, string);
|
||||
@@ -1053,15 +990,13 @@ EXPORT_SYMBOL(__debug_sprintf_event);
|
||||
/*
|
||||
* debug_sprintf_exception:
|
||||
*/
|
||||
|
||||
debug_entry_t*
|
||||
__debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
|
||||
debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int numargs,idx;
|
||||
unsigned long flags;
|
||||
debug_sprintf_entry_t *curr_event;
|
||||
debug_entry_t *active;
|
||||
unsigned long flags;
|
||||
int numargs, idx;
|
||||
va_list ap;
|
||||
|
||||
if (!debug_active || !id->areas)
|
||||
return NULL;
|
||||
@@ -1071,8 +1006,9 @@ __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
|
||||
if (debug_critical) {
|
||||
if (!spin_trylock_irqsave(&id->lock, flags))
|
||||
return NULL;
|
||||
} else
|
||||
} else {
|
||||
spin_lock_irqsave(&id->lock, flags);
|
||||
}
|
||||
active = get_active_entry(id);
|
||||
curr_event = (debug_sprintf_entry_t *)DEBUG_DATA(active);
|
||||
va_start(ap, string);
|
||||
@@ -1090,15 +1026,13 @@ EXPORT_SYMBOL(__debug_sprintf_exception);
|
||||
/*
|
||||
* debug_register_view:
|
||||
*/
|
||||
|
||||
int
|
||||
debug_register_view(debug_info_t * id, struct debug_view *view)
|
||||
int debug_register_view(debug_info_t *id, struct debug_view *view)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct dentry *pde;
|
||||
umode_t mode;
|
||||
int rc = 0;
|
||||
int i;
|
||||
unsigned long flags;
|
||||
umode_t mode;
|
||||
struct dentry *pde;
|
||||
|
||||
if (!id)
|
||||
goto out;
|
||||
@@ -1139,9 +1073,7 @@ EXPORT_SYMBOL(debug_register_view);
|
||||
/*
|
||||
* debug_unregister_view:
|
||||
*/
|
||||
|
||||
int
|
||||
debug_unregister_view(debug_info_t * id, struct debug_view *view)
|
||||
int debug_unregister_view(debug_info_t *id, struct debug_view *view)
|
||||
{
|
||||
struct dentry *dentry = NULL;
|
||||
unsigned long flags;
|
||||
@@ -1154,9 +1086,9 @@ debug_unregister_view(debug_info_t * id, struct debug_view *view)
|
||||
if (id->views[i] == view)
|
||||
break;
|
||||
}
|
||||
if (i == DEBUG_MAX_VIEWS)
|
||||
if (i == DEBUG_MAX_VIEWS) {
|
||||
rc = -1;
|
||||
else {
|
||||
} else {
|
||||
dentry = id->debugfs_entries[i];
|
||||
id->views[i] = NULL;
|
||||
id->debugfs_entries[i] = NULL;
|
||||
@@ -1168,8 +1100,8 @@ out:
|
||||
}
|
||||
EXPORT_SYMBOL(debug_unregister_view);
|
||||
|
||||
static inline char *
|
||||
debug_get_user_string(const char __user *user_buf, size_t user_len)
|
||||
static inline char *debug_get_user_string(const char __user *user_buf,
|
||||
size_t user_len)
|
||||
{
|
||||
char *buffer;
|
||||
|
||||
@@ -1188,16 +1120,14 @@ debug_get_user_string(const char __user *user_buf, size_t user_len)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static inline int
|
||||
debug_get_uint(char *buf)
|
||||
static inline int debug_get_uint(char *buf)
|
||||
{
|
||||
int rc;
|
||||
|
||||
buf = skip_spaces(buf);
|
||||
rc = simple_strtoul(buf, &buf, 10);
|
||||
if(*buf){
|
||||
if (*buf)
|
||||
rc = -EINVAL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1210,9 +1140,8 @@ debug_get_uint(char *buf)
|
||||
* prints out actual debug level
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_prolog_pages_fn(debug_info_t * id,
|
||||
struct debug_view *view, char *out_buf)
|
||||
static int debug_prolog_pages_fn(debug_info_t *id, struct debug_view *view,
|
||||
char *out_buf)
|
||||
{
|
||||
return sprintf(out_buf, "%i\n", id->pages_per_area);
|
||||
}
|
||||
@@ -1221,13 +1150,12 @@ debug_prolog_pages_fn(debug_info_t * id,
|
||||
* reads new size (number of pages per debug area)
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_input_pages_fn(debug_info_t *id, struct debug_view *view,
|
||||
struct file *file, const char __user *user_buf,
|
||||
size_t user_len, loff_t *offset)
|
||||
{
|
||||
char *str;
|
||||
int rc, new_pages;
|
||||
char *str;
|
||||
|
||||
if (user_len > 0x10000)
|
||||
user_len = 0x10000;
|
||||
@@ -1261,32 +1189,27 @@ out:
|
||||
/*
|
||||
* prints out actual debug level
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_prolog_level_fn(debug_info_t * id, struct debug_view *view, char *out_buf)
|
||||
static int debug_prolog_level_fn(debug_info_t *id, struct debug_view *view,
|
||||
char *out_buf)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if(id->level == DEBUG_OFF_LEVEL) {
|
||||
if (id->level == DEBUG_OFF_LEVEL)
|
||||
rc = sprintf(out_buf, "-\n");
|
||||
}
|
||||
else {
|
||||
else
|
||||
rc = sprintf(out_buf, "%i\n", id->level);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* reads new debug level
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_input_level_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_input_level_fn(debug_info_t *id, struct debug_view *view,
|
||||
struct file *file, const char __user *user_buf,
|
||||
size_t user_len, loff_t *offset)
|
||||
{
|
||||
char *str;
|
||||
int rc, new_level;
|
||||
char *str;
|
||||
|
||||
if (user_len > 0x10000)
|
||||
user_len = 0x10000;
|
||||
@@ -1320,11 +1243,9 @@ out:
|
||||
return rc; /* number of input characters */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* flushes debug areas
|
||||
*/
|
||||
|
||||
static void debug_flush(debug_info_t *id, int area)
|
||||
{
|
||||
unsigned long flags;
|
||||
@@ -1338,26 +1259,22 @@ static void debug_flush(debug_info_t* id, int area)
|
||||
memset(id->active_entries, 0, id->nr_areas * sizeof(int));
|
||||
for (i = 0; i < id->nr_areas; i++) {
|
||||
id->active_pages[i] = 0;
|
||||
for(j = 0; j < id->pages_per_area; j++) {
|
||||
for (j = 0; j < id->pages_per_area; j++)
|
||||
memset(id->areas[i][j], 0, PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
} else if (area >= 0 && area < id->nr_areas) {
|
||||
id->active_entries[area] = 0;
|
||||
id->active_pages[area] = 0;
|
||||
for(i = 0; i < id->pages_per_area; i++) {
|
||||
for (i = 0; i < id->pages_per_area; i++)
|
||||
memset(id->areas[area][i], 0, PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&id->lock, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* view function: flushes debug areas
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_input_flush_fn(debug_info_t *id, struct debug_view *view,
|
||||
struct file *file, const char __user *user_buf,
|
||||
size_t user_len, loff_t *offset)
|
||||
{
|
||||
@@ -1380,6 +1297,7 @@ debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
|
||||
}
|
||||
if (isdigit(input_buf[0])) {
|
||||
int area = ((int) input_buf[0] - (int) '0');
|
||||
|
||||
debug_flush(id, area);
|
||||
goto out;
|
||||
}
|
||||
@@ -1395,9 +1313,7 @@ out:
|
||||
/*
|
||||
* prints debug header in raw format
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_raw_header_fn(debug_info_t *id, struct debug_view *view,
|
||||
int area, debug_entry_t *entry, char *out_buf)
|
||||
{
|
||||
int rc;
|
||||
@@ -1410,9 +1326,7 @@ debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
|
||||
/*
|
||||
* prints debug data in raw format
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_raw_format_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_raw_format_fn(debug_info_t *id, struct debug_view *view,
|
||||
char *out_buf, const char *in_buf)
|
||||
{
|
||||
int rc;
|
||||
@@ -1425,20 +1339,17 @@ debug_raw_format_fn(debug_info_t * id, struct debug_view *view,
|
||||
/*
|
||||
* prints debug data in hex/ascii format
|
||||
*/
|
||||
|
||||
static int
|
||||
debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_hex_ascii_format_fn(debug_info_t *id, struct debug_view *view,
|
||||
char *out_buf, const char *in_buf)
|
||||
{
|
||||
int i, rc = 0;
|
||||
|
||||
for (i = 0; i < id->buf_size; i++) {
|
||||
rc += sprintf(out_buf + rc, "%02x ",
|
||||
((unsigned char *) in_buf)[i]);
|
||||
}
|
||||
for (i = 0; i < id->buf_size; i++)
|
||||
rc += sprintf(out_buf + rc, "%02x ", ((unsigned char *) in_buf)[i]);
|
||||
rc += sprintf(out_buf + rc, "| ");
|
||||
for (i = 0; i < id->buf_size; i++) {
|
||||
unsigned char c = in_buf[i];
|
||||
|
||||
if (isascii(c) && isprint(c))
|
||||
rc += sprintf(out_buf + rc, "%c", c);
|
||||
else
|
||||
@@ -1451,16 +1362,14 @@ debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
|
||||
/*
|
||||
* prints header for debug entry
|
||||
*/
|
||||
|
||||
int
|
||||
debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
|
||||
int debug_dflt_header_fn(debug_info_t *id, struct debug_view *view,
|
||||
int area, debug_entry_t *entry, char *out_buf)
|
||||
{
|
||||
unsigned long base, sec, usec;
|
||||
char *except_str;
|
||||
unsigned long caller;
|
||||
int rc = 0;
|
||||
unsigned int level;
|
||||
char *except_str;
|
||||
int rc = 0;
|
||||
|
||||
level = entry->id.fields.level;
|
||||
base = (*(unsigned long *) &tod_clock_base[0]) >> 4;
|
||||
@@ -1486,8 +1395,7 @@ EXPORT_SYMBOL(debug_dflt_header_fn);
|
||||
|
||||
#define DEBUG_SPRINTF_MAX_ARGS 10
|
||||
|
||||
static int
|
||||
debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
|
||||
static int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
|
||||
char *out_buf, debug_sprintf_entry_t *curr_event)
|
||||
{
|
||||
int num_longs, num_used_args = 0, i, rc = 0;
|
||||
@@ -1519,9 +1427,7 @@ debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
|
||||
curr_event->args[index[5]], curr_event->args[index[6]],
|
||||
curr_event->args[index[7]], curr_event->args[index[8]],
|
||||
curr_event->args[index[9]]);
|
||||
|
||||
out:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user