hwmon: (dell-smm) Rework SMM function debugging
[linux-2.6-microblaze.git] / drivers / hwmon / dell-smm-hwmon.c
index 2064184..774c1b0 100644 (file)
@@ -158,17 +158,12 @@ static inline const char __init *i8k_get_dmi_data(int field)
  */
 static int i8k_smm_func(void *par)
 {
-       int rc;
+       ktime_t calltime = ktime_get();
        struct smm_regs *regs = par;
        int eax = regs->eax;
-
-#ifdef DEBUG
        int ebx = regs->ebx;
-       unsigned long duration;
-       ktime_t calltime, delta, rettime;
-
-       calltime = ktime_get();
-#endif
+       long long duration;
+       int rc;
 
        /* SMM requires CPU 0 */
        if (smp_processor_id() != 0)
@@ -230,13 +225,9 @@ static int i8k_smm_func(void *par)
        if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
                rc = -EINVAL;
 
-#ifdef DEBUG
-       rettime = ktime_get();
-       delta = ktime_sub(rettime, calltime);
-       duration = ktime_to_ns(delta) >> 10;
-       pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x  (took %7lu usecs)\n", eax, ebx,
-               (rc ? 0xffff : regs->eax & 0xffff), duration);
-#endif
+       duration = ktime_us_delta(ktime_get(), calltime);
+       pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x  (took %7lld usecs)\n", eax, ebx,
+                (rc ? 0xffff : regs->eax & 0xffff), duration);
 
        return rc;
 }
@@ -248,9 +239,9 @@ static int i8k_smm(struct smm_regs *regs)
 {
        int ret;
 
-       get_online_cpus();
+       cpus_read_lock();
        ret = smp_call_on_cpu(0, i8k_smm_func, regs, true);
-       put_online_cpus();
+       cpus_read_unlock();
 
        return ret;
 }
@@ -309,7 +300,7 @@ static int i8k_get_fan_type(struct dell_smm_data *data, int fan)
 /*
  * Read the fan nominal rpm for specific fan speed.
  */
-static int i8k_get_fan_nominal_speed(const struct dell_smm_data *data, int fan, int speed)
+static int __init i8k_get_fan_nominal_speed(const struct dell_smm_data *data, int fan, int speed)
 {
        struct smm_regs regs = { .eax = I8K_SMM_GET_NOM_SPEED, };
 
@@ -957,7 +948,7 @@ enum i8k_configs {
        DELL_XPS,
 };
 
-static const struct i8k_config_data i8k_config_data[] = {
+static const struct i8k_config_data i8k_config_data[] __initconst = {
        [DELL_LATITUDE_D520] = {
                .fan_mult = 1,
                .fan_max = I8K_FAN_TURBO,
@@ -1115,7 +1106,7 @@ static const struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initconst
  * support for affected blacklisted Dell machines stay disabled.
  * See bug: https://bugzilla.kernel.org/show_bug.cgi?id=195751
  */
-static struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initdata = {
+static const struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initconst = {
        {
                .ident = "Dell Inspiron 7720",
                .matches = {
@@ -1156,22 +1147,14 @@ enum i8k_fan_controls {
        I8K_FAN_34A3_35A3,
 };
 
-static const struct i8k_fan_control_data i8k_fan_control_data[] = {
+static const struct i8k_fan_control_data i8k_fan_control_data[] __initconst = {
        [I8K_FAN_34A3_35A3] = {
                .manual_fan = 0x34a3,
                .auto_fan = 0x35a3,
        },
 };
 
-static struct dmi_system_id i8k_whitelist_fan_control[] __initdata = {
-       {
-               .ident = "Dell Precision 5530",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Precision 5530"),
-               },
-               .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3],
-       },
+static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = {
        {
                .ident = "Dell Latitude 5480",
                .matches = {
@@ -1196,6 +1179,22 @@ static struct dmi_system_id i8k_whitelist_fan_control[] __initdata = {
                },
                .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3],
        },
+       {
+               .ident = "Dell Precision 5530",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Precision 5530"),
+               },
+               .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3],
+       },
+       {
+               .ident = "Dell Precision 7510",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Precision 7510"),
+               },
+               .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3],
+       },
        { }
 };