Print this page
XXXX don't fail device detach when it's physically removed


15040                 parent = pdip;
15041                 cdip = rdip;
15042         } else {
15043                 return (DDI_FAILURE);
15044         }
15045 
15046         /*
15047          * Make sure node is attached otherwise
15048          * it won't have related cache nodes to
15049          * clean up.  i_ddi_devi_attached is
15050          * similiar to i_ddi_node_state(cdip) >=
15051          * DS_ATTACHED.
15052          */
15053         if (i_ddi_devi_attached(cdip)) {
15054 
15055                 /* Get full devname */
15056                 devname = kmem_alloc(MAXNAMELEN + 1, KM_SLEEP);
15057                 (void) ddi_deviname(cdip, devname);
15058                 /* Clean cache */
15059                 (void) devfs_clean(parent, devname + 1,
15060                     DV_CLEAN_FORCE);
15061                 kmem_free(devname, MAXNAMELEN + 1);
15062         }
15063         if (rpip != NULL) {
15064                 if (MDI_PI_IS_OFFLINE(rpip)) {
15065                         rval = DDI_SUCCESS;
15066                 } else {
15067                         rval = mdi_pi_offline(rpip, 0);
15068                 }
15069         } else {
15070                 rval = ndi_devi_offline(cdip, flags);
15071         }
15072 
15073         return (rval);
15074 }
15075 
15076 static dev_info_t *
15077 mptsas_find_smp_child(dev_info_t *parent, char *str_wwn)
15078 {
15079         dev_info_t      *child = NULL;
15080         char            *smp_wwn = NULL;


15110 
15111         cdip = mptsas_find_smp_child(pdip, wwn_str);
15112 
15113         if (cdip == NULL)
15114                 return (DDI_SUCCESS);
15115 
15116         /*
15117          * Make sure node is attached otherwise
15118          * it won't have related cache nodes to
15119          * clean up.  i_ddi_devi_attached is
15120          * similiar to i_ddi_node_state(cdip) >=
15121          * DS_ATTACHED.
15122          */
15123         if (i_ddi_devi_attached(cdip)) {
15124 
15125                 /* Get full devname */
15126                 devname = kmem_alloc(MAXNAMELEN + 1, KM_SLEEP);
15127                 (void) ddi_deviname(cdip, devname);
15128                 /* Clean cache */
15129                 (void) devfs_clean(pdip, devname + 1,
15130                     DV_CLEAN_FORCE);
15131                 kmem_free(devname, MAXNAMELEN + 1);
15132         }
15133 
15134         rval = ndi_devi_offline(cdip, flags);
15135 
15136         return (rval);
15137 }
15138 
15139 static dev_info_t *
15140 mptsas_find_child(dev_info_t *pdip, char *name)
15141 {
15142         dev_info_t      *child = NULL;
15143         char            *rname = NULL;
15144         int             rval = DDI_FAILURE;
15145 
15146         rname = kmem_zalloc(SCSI_MAXNAMELEN, KM_SLEEP);
15147 
15148         child = ddi_get_child(pdip);
15149         while (child) {
15150                 rval = mptsas_name_child(child, rname, SCSI_MAXNAMELEN);




15040                 parent = pdip;
15041                 cdip = rdip;
15042         } else {
15043                 return (DDI_FAILURE);
15044         }
15045 
15046         /*
15047          * Make sure node is attached otherwise
15048          * it won't have related cache nodes to
15049          * clean up.  i_ddi_devi_attached is
15050          * similiar to i_ddi_node_state(cdip) >=
15051          * DS_ATTACHED.
15052          */
15053         if (i_ddi_devi_attached(cdip)) {
15054 
15055                 /* Get full devname */
15056                 devname = kmem_alloc(MAXNAMELEN + 1, KM_SLEEP);
15057                 (void) ddi_deviname(cdip, devname);
15058                 /* Clean cache */
15059                 (void) devfs_clean(parent, devname + 1,
15060                     DV_CLEAN_FORCE|DV_DEVI_GONE);
15061                 kmem_free(devname, MAXNAMELEN + 1);
15062         }
15063         if (rpip != NULL) {
15064                 if (MDI_PI_IS_OFFLINE(rpip)) {
15065                         rval = DDI_SUCCESS;
15066                 } else {
15067                         rval = mdi_pi_offline(rpip, 0);
15068                 }
15069         } else {
15070                 rval = ndi_devi_offline(cdip, flags);
15071         }
15072 
15073         return (rval);
15074 }
15075 
15076 static dev_info_t *
15077 mptsas_find_smp_child(dev_info_t *parent, char *str_wwn)
15078 {
15079         dev_info_t      *child = NULL;
15080         char            *smp_wwn = NULL;


15110 
15111         cdip = mptsas_find_smp_child(pdip, wwn_str);
15112 
15113         if (cdip == NULL)
15114                 return (DDI_SUCCESS);
15115 
15116         /*
15117          * Make sure node is attached otherwise
15118          * it won't have related cache nodes to
15119          * clean up.  i_ddi_devi_attached is
15120          * similiar to i_ddi_node_state(cdip) >=
15121          * DS_ATTACHED.
15122          */
15123         if (i_ddi_devi_attached(cdip)) {
15124 
15125                 /* Get full devname */
15126                 devname = kmem_alloc(MAXNAMELEN + 1, KM_SLEEP);
15127                 (void) ddi_deviname(cdip, devname);
15128                 /* Clean cache */
15129                 (void) devfs_clean(pdip, devname + 1,
15130                     DV_CLEAN_FORCE|DV_DEVI_GONE);
15131                 kmem_free(devname, MAXNAMELEN + 1);
15132         }
15133 
15134         rval = ndi_devi_offline(cdip, flags);
15135 
15136         return (rval);
15137 }
15138 
15139 static dev_info_t *
15140 mptsas_find_child(dev_info_t *pdip, char *name)
15141 {
15142         dev_info_t      *child = NULL;
15143         char            *rname = NULL;
15144         int             rval = DDI_FAILURE;
15145 
15146         rname = kmem_zalloc(SCSI_MAXNAMELEN, KM_SLEEP);
15147 
15148         child = ddi_get_child(pdip);
15149         while (child) {
15150                 rval = mptsas_name_child(child, rname, SCSI_MAXNAMELEN);