]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
staging: mei: adding watchdog ops
authorOren Weil <oren.jer.weil@intel.com>
Wed, 7 Sep 2011 06:03:10 +0000 (09:03 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 9 Sep 2011 20:28:20 +0000 (13:28 -0700)
adding start and stop function.
start - check if AMT wd client is connected, which is been connected on driver
load.
stop - send stop command to AMT wd.

Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/mei/main.c
drivers/staging/mei/mei_dev.h
drivers/staging/mei/wd.c

index c4ebd07a2ddc64fdd960423593001fd3101ad65a..386c27952d13b9f8858b830f39c2a934f1f8afe6 100644 (file)
@@ -58,7 +58,7 @@ static struct cdev mei_cdev;
 static int mei_major;
 /* The device pointer */
 /* Currently this driver works as long as there is only a single AMT device. */
-static struct pci_dev *mei_device;
+struct pci_dev *mei_device;
 
 static struct class *mei_class;
 
index d434afc3ffea0a55d23e8e06d536da4716070c94..43d7e1c044108de082ac50164545810e562f7399 100644 (file)
 #define MEI_WD_PARAMS_SIZE             4
 #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT       (1 << 0)
 
+/*
+ * MEI PCI Device object
+ */
+extern struct pci_dev *mei_device;
+
 /*
  * AMT Watchdog Device
  */
index d9e41a7a5afca24f883c0dd384797ac0b16d7715..fb2bd3d43346c1f0b61dfd4bf10a3d1735f3884a 100644 (file)
 #include "interface.h"
 #include "mei.h"
 
-/*
- * Watchdog Device structs
- */
-const struct watchdog_info wd_info = {
-               .identity = INTEL_AMT_WATCHDOG_ID,
-};
-
-struct watchdog_device amt_wd_dev = {
-               .info = &wd_info,
-               .timeout = AMT_WD_DEFAULT_TIMEOUT,
-               .min_timeout = AMT_WD_MIN_TIMEOUT,
-               .max_timeout = AMT_WD_MAX_TIMEOUT,
-};
-
-
 /*
  * MEI Watchdog Module Parameters
  */
@@ -210,3 +195,83 @@ out:
        return ret;
 }
 
+/*
+ * mei_wd_ops_start - wd start command from the watchdog core.
+ *
+ * @wd_dev - watchdog device struct
+ *
+ * returns 0 if success, negative errno code for failure
+ */
+static int mei_wd_ops_start(struct watchdog_device *wd_dev)
+{
+       int err = -ENODEV;
+       struct mei_device *dev;
+
+       dev = pci_get_drvdata(mei_device);
+       if (!dev)
+               return -ENODEV;
+
+       mutex_lock(&dev->device_lock);
+
+       if (dev->mei_state != MEI_ENABLED) {
+               dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED  mei_state= %d\n",
+                   dev->mei_state);
+               goto end_unlock;
+       }
+
+       if (dev->wd_cl.state != MEI_FILE_CONNECTED)     {
+               dev_dbg(&dev->pdev->dev, "MEI Driver is not connected to Watchdog Client\n");
+               goto end_unlock;
+       }
+
+       mei_wd_start_setup(dev);
+
+       err = 0;
+end_unlock:
+       mutex_unlock(&dev->device_lock);
+       return err;
+}
+
+/*
+ * mei_wd_ops_stop -  wd stop command from the watchdog core.
+ *
+ * @wd_dev - watchdog device struct
+ *
+ * returns 0 if success, negative errno code for failure
+ */
+static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
+{
+       struct mei_device *dev;
+       dev = pci_get_drvdata(mei_device);
+
+       if (!dev)
+               return -ENODEV;
+
+       mutex_lock(&dev->device_lock);
+       mei_wd_stop(dev, false);
+       mutex_unlock(&dev->device_lock);
+
+       return 0;
+}
+
+/*
+ * Watchdog Device structs
+ */
+const struct watchdog_ops wd_ops = {
+               .owner = THIS_MODULE,
+               .start = mei_wd_ops_start,
+               .stop = mei_wd_ops_stop,
+};
+const struct watchdog_info wd_info = {
+               .identity = INTEL_AMT_WATCHDOG_ID,
+};
+
+struct watchdog_device amt_wd_dev = {
+               .info = &wd_info,
+               .ops = &wd_ops,
+               .timeout = AMT_WD_DEFAULT_TIMEOUT,
+               .min_timeout = AMT_WD_MIN_TIMEOUT,
+               .max_timeout = AMT_WD_MAX_TIMEOUT,
+};
+
+