public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] dca: use DEFINE_SPINLOCK() for spinlock and DEFINE_IDR() for idr
@ 2021-04-09  9:51 Ye Bin
  0 siblings, 0 replies; only message in thread
From: Ye Bin @ 2021-04-09  9:51 UTC (permalink / raw)
  To: yebin10, Zhang Shengju, Tang Bin, Greg Kroah-Hartman
  Cc: linux-kernel, kernel-janitors, Hulk Robot

spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().
idr can be initialized automatically with DEFINE_IDR()
rather than explicitly calling idr_init().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/dca/dca-sysfs.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index 21ebd0af268b..c56e917f0f19 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -14,8 +14,8 @@
 #include <linux/export.h>
 
 static struct class *dca_class;
-static struct idr dca_idr;
-static spinlock_t dca_idr_lock;
+static DEFINE_IDR(dca_idr);
+static DEFINE_SPINLOCK(dca_idr_lock);
 
 int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot)
 {
@@ -71,9 +71,6 @@ void dca_sysfs_remove_provider(struct dca_provider *dca)
 
 int __init dca_sysfs_init(void)
 {
-	idr_init(&dca_idr);
-	spin_lock_init(&dca_idr_lock);
-
 	dca_class = class_create(THIS_MODULE, "dca");
 	if (IS_ERR(dca_class)) {
 		idr_destroy(&dca_idr);


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-09  9:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-09  9:51 [PATCH -next] dca: use DEFINE_SPINLOCK() for spinlock and DEFINE_IDR() for idr Ye Bin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox