Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jan 2020 22:19:55 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357181 - in head/sys: arm/allwinner cam/mmc dev/mmc/host dev/sdhci
Message-ID:  <202001272219.00RMJtg1086033@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Mon Jan 27 22:19:55 2020
New Revision: 357181
URL: https://svnweb.freebsd.org/changeset/base/357181

Log:
  Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. Pass
  in the parameters needed for the different sims, but it's almost all identical.

Modified:
  head/sys/arm/allwinner/aw_mmc.c
  head/sys/cam/mmc/mmc_all.h
  head/sys/cam/mmc/mmc_xpt.c
  head/sys/dev/mmc/host/dwmmc.c
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/arm/allwinner/aw_mmc.c
==============================================================================
--- head/sys/arm/allwinner/aw_mmc.c	Mon Jan 27 22:13:42 2020	(r357180)
+++ head/sys/arm/allwinner/aw_mmc.c	Mon Jan 27 22:19:55 2020	(r357181)
@@ -213,33 +213,11 @@ aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb)
 
 	switch (ccb->ccb_h.func_code) {
 	case XPT_PATH_INQ:
-	{
-		struct ccb_pathinq *cpi;
-
-		cpi = &ccb->cpi;
-		cpi->version_num = 1;
-		cpi->hba_inquiry = 0;
-		cpi->target_sprt = 0;
-		cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
-		cpi->hba_eng_cnt = 0;
-		cpi->max_target = 0;
-		cpi->max_lun = 0;
-		cpi->initiator_id = 1;
-		cpi->maxio = (sc->aw_mmc_conf->dma_xferlen *
-			      AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE;
-		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-		strncpy(cpi->hba_vid, "Deglitch Networks", HBA_IDLEN);
-		strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
-		cpi->unit_number = cam_sim_unit(sim);
-		cpi->bus_id = cam_sim_bus(sim);
-		cpi->protocol = PROTO_MMCSD;
-		cpi->protocol_version = SCSI_REV_0;
-		cpi->transport = XPORT_MMCSD;
-		cpi->transport_version = 1;
-
-		cpi->ccb_h.status = CAM_REQ_CMP;
+		mmc_path_inq(&ccb->cpi, "Deglitch Networks", sim,
+		    (sc->aw_mmc_conf->dma_xferlen * AW_MMC_DMA_SEGS) /
+		    MMC_SECTOR_SIZE);
 		break;
-	}
+
 	case XPT_GET_TRAN_SETTINGS:
 	{
 		struct ccb_trans_settings *cts = &ccb->cts;

Modified: head/sys/cam/mmc/mmc_all.h
==============================================================================
--- head/sys/cam/mmc/mmc_all.h	Mon Jan 27 22:13:42 2020	(r357180)
+++ head/sys/cam/mmc/mmc_all.h	Mon Jan 27 22:19:55 2020	(r357181)
@@ -68,5 +68,9 @@
 #include <dev/mmc/mmcreg.h>
 
 void	mmc_print_ident(struct mmc_params *ident_data);
+struct ccb_pathinq;
+struct cam_sim;
+void	mmc_path_inq(struct ccb_pathinq *cpi, const char *hba,
+    const struct cam_sim *sim, size_t maxio);
 
 #endif

Modified: head/sys/cam/mmc/mmc_xpt.c
==============================================================================
--- head/sys/cam/mmc/mmc_xpt.c	Mon Jan 27 22:13:42 2020	(r357180)
+++ head/sys/cam/mmc/mmc_xpt.c	Mon Jan 27 22:19:55 2020	(r357181)
@@ -1104,3 +1104,32 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do
                 cam_periph_release_locked(periph);
         }
 }
+
+void
+mmc_path_inq(struct ccb_pathinq *cpi, const char *hba,
+    const struct cam_sim *sim, size_t maxio)
+{
+
+	cpi->version_num = 1;
+	cpi->hba_inquiry = 0;
+	cpi->target_sprt = 0;
+	cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
+	cpi->hba_eng_cnt = 0;
+	cpi->max_target = 0;
+	cpi->max_lun = 0;
+	cpi->initiator_id = 1;
+	cpi->maxio = maxio;
+	strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+	strncpy(cpi->hba_vid, hba, HBA_IDLEN);
+	strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+	cpi->unit_number = cam_sim_unit(sim);
+	cpi->bus_id = cam_sim_bus(sim);
+	cpi->protocol = PROTO_MMCSD;
+	cpi->protocol_version = SCSI_REV_0;
+	cpi->transport = XPORT_MMCSD;
+	cpi->transport_version = 1;
+
+	cpi->base_transfer_speed = 100; /* XXX WTF? */
+
+	cpi->ccb_h.status = CAM_REQ_CMP;
+}

Modified: head/sys/dev/mmc/host/dwmmc.c
==============================================================================
--- head/sys/dev/mmc/host/dwmmc.c	Mon Jan 27 22:13:42 2020	(r357180)
+++ head/sys/dev/mmc/host/dwmmc.c	Mon Jan 27 22:19:55 2020	(r357181)
@@ -67,8 +67,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/mmc/host/dwmmc_reg.h>
 #include <dev/mmc/host/dwmmc_var.h>
 
-#include "opt_mmccam.h"
-
 #include "mmcbr_if.h"
 
 #define dprintf(x, arg...)

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c	Mon Jan 27 22:13:42 2020	(r357180)
+++ head/sys/dev/sdhci/sdhci.c	Mon Jan 27 22:19:55 2020	(r357181)
@@ -2586,33 +2586,9 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb)
 
 	switch (ccb->ccb_h.func_code) {
 	case XPT_PATH_INQ:
-	{
-		struct ccb_pathinq *cpi;
-
-		cpi = &ccb->cpi;
-		cpi->version_num = 1;
-		cpi->hba_inquiry = 0;
-		cpi->target_sprt = 0;
-		cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
-		cpi->hba_eng_cnt = 0;
-		cpi->max_target = 0;
-		cpi->max_lun = 0;
-		cpi->initiator_id = 1;
-		cpi->maxio = MAXPHYS;
-		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-		strncpy(cpi->hba_vid, "Deglitch Networks", HBA_IDLEN);
-		strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
-		cpi->unit_number = cam_sim_unit(sim);
-		cpi->bus_id = cam_sim_bus(sim);
-		cpi->base_transfer_speed = 100; /* XXX WTF? */
-		cpi->protocol = PROTO_MMCSD;
-		cpi->protocol_version = SCSI_REV_0;
-		cpi->transport = XPORT_MMCSD;
-		cpi->transport_version = 0;
-
-		cpi->ccb_h.status = CAM_REQ_CMP;
+		mmc_path_inq(&ccb->cpi, "Deglitch Networks", sim, MAXPHYS);
 		break;
-	}
+
 	case XPT_GET_TRAN_SETTINGS:
 	{
 		struct ccb_trans_settings *cts = &ccb->cts;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001272219.00RMJtg1086033>