mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Jean Delvare <khali@linux-fr.org>
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 12/12] hwmon: (nct6775) Only report VID if supported and enabled
Date: Tue, 26 Feb 2013 10:23:40 -0800	[thread overview]
Message-ID: <1361903020-18526-13-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1361903020-18526-1-git-send-email-linux@roeck-us.net>

VID is not always enabled (NCT6775, NCT6776) or supported (NCT6779).

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/nct6775.c |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index a4b076a..aeeb0a1 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -3398,6 +3398,8 @@ static int nct6775_probe(struct platform_device *pdev)
 	const u16 *reg_temp, *reg_temp_over, *reg_temp_hyst, *reg_temp_config;
 	const u16 *reg_temp_alternate, *reg_temp_crit;
 	int num_reg_temp;
+	bool have_vid = false;
+	u8 cr2a;
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
 	if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
@@ -3766,17 +3768,31 @@ static int nct6775_probe(struct platform_device *pdev)
 	/* Initialize the chip */
 	nct6775_init_device(data);
 
-	data->vrm = vid_which_vrm();
 	err = superio_enter(sio_data->sioreg);
 	if (err)
 		return err;
 
+	cr2a = superio_inb(sio_data->sioreg, 0x2a);
+	switch (data->kind) {
+	case nct6775:
+		have_vid = (cr2a & 0x40);
+		break;
+	case nct6776:
+		have_vid = (cr2a & 0x60) == 0x40;
+		break;
+	case nct6779:
+		break;
+	}
+
 	/*
 	 * Read VID value
 	 * We can get the VID input values directly at logical device D 0xe3.
 	 */
-	superio_select(sio_data->sioreg, NCT6775_LD_VID);
-	data->vid = superio_inb(sio_data->sioreg, 0xe3);
+	if (have_vid) {
+		superio_select(sio_data->sioreg, NCT6775_LD_VID);
+		data->vid = superio_inb(sio_data->sioreg, 0xe3);
+		data->vrm = vid_which_vrm();
+	}
 
 	if (fan_debounce) {
 		u8 tmp;
@@ -3801,9 +3817,11 @@ static int nct6775_probe(struct platform_device *pdev)
 
 	superio_exit(sio_data->sioreg);
 
-	err = device_create_file(dev, &dev_attr_cpu0_vid);
-	if (err)
-		return err;
+	if (have_vid) {
+		err = device_create_file(dev, &dev_attr_cpu0_vid);
+		if (err)
+			return err;
+	}
 
 	err = nct6775_check_fan_inputs(sio_data, data);
 	if (err)
-- 
1.7.9.7


      parent reply	other threads:[~2013-02-26 18:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 18:23 [PATCH v6 00/12] hwmon: Driver for Nuvoton NCT6775F, NCT6776F, and NCT6779D Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 01/12] " Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 02/12] hwmon: (nct6775) Add case open detection Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 03/12] hwmon: (nct6775) Add support for temperature sensors Guenter Roeck
2013-02-26 18:35   ` Joe Perches
2013-02-26 19:41     ` Guenter Roeck
2013-02-27 17:44   ` [PATCH v6 " Guenter Roeck
2013-02-26 18:23 ` [PATCH v6 04/12] hwmon: (nct6775) Add support for fan speed attributes Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 05/12] hwmon: (nct6775) Add support for fanX_pulses sysfs attribute Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 06/12] hwmon: (nct6775) Add support for fan debounce module parameter Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 07/12] hwmon: (nct6775) Add power management support Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 08/12] hwmon: (nct6775) Add support for pwm, pwm_mode, and pwm_enable Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 09/12] hwmon: (nct6775) Add support for automatic fan control Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 10/12] hwmon: (nct6775) Add support for weighted " Guenter Roeck
2013-02-26 18:23 ` [PATCH v5 11/12] hwmon: (nct6775) Detect and report additional temperature sources Guenter Roeck
2013-02-26 18:23 ` Guenter Roeck [this message]

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=1361903020-18526-13-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    /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®