lkml.org 
[lkml]   [2020]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 23/24] kset-example: add pr_debug()s for easy visibility of its operation
Date
put pr_debug()s into most functions, to easily see code operate when
module is loaded and used.

#> dmesg -w &
#> modprobe kset-example dyndbg=+pfml
#> cat /sys/kernel/kset-example/*/*
---
samples/kobject/kset-example.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
index c8010f126808..27c9b1beec28 100644
--- a/samples/kobject/kset-example.c
+++ b/samples/kobject/kset-example.c
@@ -56,6 +56,7 @@ static ssize_t foo_attr_show(struct kobject *kobj,
struct foo_attribute *attribute;
struct foo_obj *foo;

+ pr_debug("called");
attribute = to_foo_attr(attr);
foo = to_foo_obj(kobj);

@@ -76,6 +77,7 @@ static ssize_t foo_attr_store(struct kobject *kobj,
struct foo_attribute *attribute;
struct foo_obj *foo;

+ pr_debug("called");
attribute = to_foo_attr(attr);
foo = to_foo_obj(kobj);

@@ -102,6 +104,7 @@ static void foo_release(struct kobject *kobj)
{
struct foo_obj *foo;

+ pr_debug("called");
foo = to_foo_obj(kobj);
kfree(foo);
}
@@ -112,6 +115,7 @@ static void foo_release(struct kobject *kobj)
static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
char *buf)
{
+ pr_debug("called");
return sprintf(buf, "%d\n", foo_obj->foo);
}

@@ -120,6 +124,7 @@ static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
{
int ret;

+ pr_debug("called");
ret = kstrtoint(buf, 10, &foo_obj->foo);
if (ret < 0)
return ret;
@@ -140,6 +145,7 @@ static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
{
int var;

+ pr_debug("called");
if (strcmp(attr->attr.name, "baz") == 0)
var = foo_obj->baz;
else
@@ -152,6 +158,7 @@ static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
{
int var, ret;

+ pr_debug("called");
ret = kstrtoint(buf, 10, &var);
if (ret < 0)
return ret;
@@ -201,6 +208,7 @@ static struct foo_obj *create_foo_obj(const char *name)
struct foo_obj *foo;
int retval;

+ pr_debug("called");
/* allocate the memory for the whole object */
foo = kzalloc(sizeof(*foo), GFP_KERNEL);
if (!foo)
@@ -235,11 +243,13 @@ static struct foo_obj *create_foo_obj(const char *name)

static void destroy_foo_obj(struct foo_obj *foo)
{
+ pr_debug("called");
kobject_put(&foo->kobj);
}

static int __init example_init(void)
{
+ pr_debug("called");
/*
* Create a kset with the name of "kset_example",
* located under /sys/kernel/
@@ -276,6 +286,7 @@ static int __init example_init(void)

static void __exit example_exit(void)
{
+ pr_debug("called");
destroy_foo_obj(baz_obj);
destroy_foo_obj(bar_obj);
destroy_foo_obj(foo_obj);
--
2.26.2
\
 
 \ /
  Last update: 2020-06-13 17:59    [W:0.423 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site