mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wenchao Hao <haowenchao@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <linfeilong@huawei.com>, Wu Bo <wubo40@huawei.com>,
	Zhiqiang Liu <liuzhiqiang26@huawei.com>,
	Wenchao Hao <haowenchao@huawei.com>
Subject: [PATCH] driver core: Make probe_type of driver accessible via sysfs
Date: Thu, 8 Jul 2021 20:20:10 +0800	[thread overview]
Message-ID: <20210708122010.262510-1-haowenchao@huawei.com> (raw)

Like drivers_autoprobe of bus, make probe_type of driver
accessible via sysfs, so we can get and set a driver's probe_type
happily.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
---
 drivers/base/bus.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 1f6b4bd61056..e006562cb638 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -583,6 +583,25 @@ static ssize_t uevent_store(struct device_driver *drv, const char *buf,
 }
 static DRIVER_ATTR_WO(uevent);
 
+static ssize_t probe_type_show(struct device_driver *drv, char *buf)
+{
+	return sysfs_emit(buf, "%d\n", drv->probe_type);
+}
+
+static ssize_t probe_type_store(struct device_driver *drv, const char *buf,
+		size_t count)
+{
+	if (buf[0] == '0')
+		drv->probe_type = 0;
+	else if (buf[0] == '1')
+		drv->probe_type = 1;
+	else if (buf[0] == '2')
+		drv->probe_type = 2;
+
+	return count;
+}
+static DRIVER_ATTR_RW(probe_type);
+
 /**
  * bus_add_driver - Add a driver to the bus.
  * @drv: driver.
@@ -626,6 +645,12 @@ int bus_add_driver(struct device_driver *drv)
 		printk(KERN_ERR "%s: uevent attr (%s) failed\n",
 			__func__, drv->name);
 	}
+	error = driver_create_file(drv, &driver_attr_probe_type);
+	if (error) {
+		printk(KERN_ERR "%s: probe_type attr (%s) failed\n",
+				__func__, drv->name);
+	}
+
 	error = driver_add_groups(drv, bus->drv_groups);
 	if (error) {
 		/* How the hell do we get out of this pickle? Give up */
-- 
2.27.0


             reply	other threads:[~2021-07-08 12:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 12:20 Wenchao Hao [this message]
2021-07-08 12:28 ` Greg Kroah-Hartman
2021-07-08 12:49   ` Wenchao Hao
2021-07-08 15:53     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708122010.262510-1-haowenchao@huawei.com \
    --to=haowenchao@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=rafael@kernel.org \
    --cc=wubo40@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®