]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/tidspbridge/pmgr/dev.c
Merge branch 'master' into tk71
[mv-sheeva.git] / drivers / staging / tidspbridge / pmgr / dev.c
index 4ddf03d3b1aba25aa3bcd584e4fb82e0ef7ca83b..132e960967b970b75a6441cf65127de390efe973 100644 (file)
@@ -27,7 +27,6 @@
 #include <dspbridge/dbc.h>
 
 /*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
 #include <dspbridge/ldr.h>
 #include <dspbridge/list.h>
 
@@ -85,6 +84,11 @@ struct dev_object {
        struct node_mgr *hnode_mgr;
 };
 
+struct drv_ext {
+       struct list_head link;
+       char sz_string[MAXREGPATHLENGTH];
+};
+
 /*  ----------------------------------- Globals */
 static u32 refs;               /* Module reference count */
 
@@ -143,6 +147,7 @@ int dev_create_device(struct dev_object **device_obj,
        struct io_attrs io_mgr_attrs;
        u32 num_windows;
        struct drv_object *hdrv_obj = NULL;
+       struct drv_data *drv_datap = dev_get_drvdata(bridge);
        int status = 0;
        DBC_REQUIRE(refs > 0);
        DBC_REQUIRE(device_obj != NULL);
@@ -158,10 +163,15 @@ int dev_create_device(struct dev_object **device_obj,
 
        /*  Get the Bridge driver interface functions */
        bridge_drv_entry(&drv_fxns, driver_file_name);
-       if (cfg_get_object((u32 *) &hdrv_obj, REG_DRV_OBJECT)) {
-               /* don't propogate CFG errors from this PROC function */
+
+       /* Retrieve the Object handle from the driver data */
+       if (drv_datap && drv_datap->drv_object) {
+               hdrv_obj = drv_datap->drv_object;
+       } else {
                status = -EPERM;
+               pr_err("%s: Failed to retrieve the object handle\n", __func__);
        }
+
        /* Create the device object, and pass a handle to the Bridge driver for
         * storage. */
        if (!status) {
@@ -812,18 +822,31 @@ int dev_remove_device(struct cfg_devnode *dev_node_obj)
 {
        struct dev_object *hdev_obj;    /* handle to device object */
        int status = 0;
-       struct dev_object *dev_obj;
+       struct drv_data *drv_datap = dev_get_drvdata(bridge);
+
+       if (!drv_datap)
+               status = -ENODATA;
+
+       if (!dev_node_obj)
+               status = -EFAULT;
 
        /* Retrieve the device object handle originaly stored with
         * the dev_node: */
-       status = cfg_get_dev_object(dev_node_obj, (u32 *) &hdev_obj);
        if (!status) {
-               /* Remove the Processor List */
-               dev_obj = (struct dev_object *)hdev_obj;
-               /* Destroy the device object. */
-               status = dev_destroy_device(hdev_obj);
+               /* check the device string and then store dev object */
+               if (!strcmp((char *)((struct drv_ext *)dev_node_obj)->sz_string,
+                                                               "TIOMAP1510")) {
+                       hdev_obj = drv_datap->dev_object;
+                       /* Destroy the device object. */
+                       status = dev_destroy_device(hdev_obj);
+               } else {
+                       status = -EPERM;
+               }
        }
 
+       if (status)
+               pr_err("%s: Failed, status 0x%x\n", __func__, status);
+
        return status;
 }
 
@@ -874,6 +897,7 @@ int dev_start_device(struct cfg_devnode *dev_node_obj)
        char bridge_file_name[CFG_MAXSEARCHPATHLEN] = "UMA";
        int status;
        struct mgr_object *hmgr_obj = NULL;
+       struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
        DBC_REQUIRE(refs > 0);
 
@@ -882,24 +906,27 @@ int dev_start_device(struct cfg_devnode *dev_node_obj)
                                   dev_node_obj);
        if (!status) {
                /* Store away the hdev_obj with the DEVNODE */
-               status = cfg_set_dev_object(dev_node_obj, (u32) hdev_obj);
+               if (!drv_datap || !dev_node_obj) {
+                       status = -EFAULT;
+                       pr_err("%s: Failed, status 0x%x\n", __func__, status);
+               } else if (!(strcmp((char *)dev_node_obj, "TIOMAP1510"))) {
+                       drv_datap->dev_object = (void *) hdev_obj;
+               }
+               if (!status) {
+                       /* Create the Manager Object */
+                       status = mgr_create(&hmgr_obj, dev_node_obj);
+                       if (status && !(strcmp((char *)dev_node_obj,
+                                                       "TIOMAP1510"))) {
+                               /* Ensure the device extension is NULL */
+                               drv_datap->dev_object = NULL;
+                       }
+               }
                if (status) {
                        /* Clean up */
                        dev_destroy_device(hdev_obj);
                        hdev_obj = NULL;
                }
        }
-       if (!status) {
-               /* Create the Manager Object */
-               status = mgr_create(&hmgr_obj, dev_node_obj);
-       }
-       if (status) {
-               if (hdev_obj)
-                       dev_destroy_device(hdev_obj);
-
-               /* Ensure the device extension is NULL */
-               cfg_set_dev_object(dev_node_obj, 0L);
-       }
 
        return status;
 }