Skip to content

Commit 4c6d874

Browse files
committed
platform/x86: ISST: Simplify isst_misc_reg() and isst_misc_unreg()
JIRA: https://issues.redhat.com/browse/RHEL-65196 commit 440814c Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Date: Wed Jul 31 11:42:56 2024 -0700 platform/x86: ISST: Simplify isst_misc_reg() and isst_misc_unreg() After commit '1630dc626c87 ("platform/x86: ISST: Add model specific loading for common module")' isst_misc_reg() and isst_misc_unreg() can be simplified. Since these functions are only called during module_init() and module_exit() respectively, there is no contention while calling misc_register()/misc_deregister or isst_if_cpu_info_init()/ isst_if_cpu_info_exit(). Hence remove mutex and reference counting. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240731184256.1852840-1-srinivas.pandruvada@linux.intel.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Steve Best <sbest@redhat.com>
1 parent fef71f2 commit 4c6d874

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

drivers/platform/x86/intel/speed_select_if/isst_if_common.c

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd,
651651

652652
/* Lock to prevent module registration when already opened by user space */
653653
static DEFINE_MUTEX(punit_misc_dev_open_lock);
654-
/* Lock to allow one shared misc device for all ISST interfaces */
655-
static DEFINE_MUTEX(punit_misc_dev_reg_lock);
656-
static int misc_usage_count;
657-
static int misc_device_ret;
658654
static int misc_device_open;
659655

660656
static int isst_if_open(struct inode *inode, struct file *file)
@@ -720,39 +716,23 @@ static struct miscdevice isst_if_char_driver = {
720716

721717
static int isst_misc_reg(void)
722718
{
723-
mutex_lock(&punit_misc_dev_reg_lock);
724-
if (misc_device_ret)
725-
goto unlock_exit;
726-
727-
if (!misc_usage_count) {
728-
misc_device_ret = isst_if_cpu_info_init();
729-
if (misc_device_ret)
730-
goto unlock_exit;
731-
732-
misc_device_ret = misc_register(&isst_if_char_driver);
733-
if (misc_device_ret) {
734-
isst_if_cpu_info_exit();
735-
goto unlock_exit;
736-
}
737-
}
738-
misc_usage_count++;
719+
int ret;
739720

740-
unlock_exit:
741-
mutex_unlock(&punit_misc_dev_reg_lock);
721+
ret = isst_if_cpu_info_init();
722+
if (ret)
723+
return ret;
742724

743-
return misc_device_ret;
725+
ret = misc_register(&isst_if_char_driver);
726+
if (ret)
727+
isst_if_cpu_info_exit();
728+
729+
return ret;
744730
}
745731

746732
static void isst_misc_unreg(void)
747733
{
748-
mutex_lock(&punit_misc_dev_reg_lock);
749-
if (misc_usage_count)
750-
misc_usage_count--;
751-
if (!misc_usage_count && !misc_device_ret) {
752-
misc_deregister(&isst_if_char_driver);
753-
isst_if_cpu_info_exit();
754-
}
755-
mutex_unlock(&punit_misc_dev_reg_lock);
734+
misc_deregister(&isst_if_char_driver);
735+
isst_if_cpu_info_exit();
756736
}
757737

758738
/**

0 commit comments

Comments
 (0)