1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-23 07:31:31 +00:00

Revert ABI breakage to CAM that came in with MMC/SD support in r320844.

Make it possible to retrieve mmc parameters via the XPT_GET_ADVINFO
call instead.  Convert camcontrol to the new scheme.

Reviewed by:	imp. kibab
Sponsored by:	Netflix
Differential Revision:	D13868
This commit is contained in:
Scott Long 2018-01-19 15:32:27 +00:00
parent 7326b4e68c
commit 19641ce893
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328165
4 changed files with 47 additions and 7 deletions

View File

@ -715,14 +715,50 @@ print_dev_semb(struct device_match_result *dev_result, char *tmpstr)
static int
print_dev_mmcsd(struct device_match_result *dev_result, char *tmpstr)
{
union ccb *ccb;
struct ccb_dev_advinfo *advi;
struct cam_device *dev;
struct mmc_params mmc_ident_data;
if (strlen(dev_result->mmc_ident_data.model) > 0) {
sprintf(tmpstr, "<%s>", dev_result->mmc_ident_data.model);
dev = cam_open_btl(dev_result->path_id, dev_result->target_id,
dev_result->target_lun, O_RDWR, NULL);
if (dev == NULL) {
warnx("%s", cam_errbuf);
return (1);
}
ccb = cam_getccb(dev);
if (ccb == NULL) {
warnx("couldn't allocate CCB");
cam_close_device(dev);
return (1);
}
advi = &ccb->cdai;
advi->ccb_h.flags = CAM_DIR_IN;
advi->ccb_h.func_code = XPT_DEV_ADVINFO;
advi->flags = CDAI_FLAG_NONE;
advi->buftype = CDAI_TYPE_MMC_PARAMS;
advi->bufsiz = sizeof(struct mmc_params);
advi->buf = (uint8_t *)&mmc_ident_data;
if (cam_send_ccb(dev, ccb) < 0) {
warn("error sending CAMIOCOMMAND ioctl");
cam_freeccb(ccb);
cam_close_device(dev);
return (1);
}
if (strlen(mmc_ident_data.model) > 0) {
sprintf(tmpstr, "<%s>", mmc_ident_data.model);
} else {
sprintf(tmpstr, "<%s card>",
dev_result->mmc_ident_data.card_features &
mmc_ident_data.card_features &
CARD_FEATURE_SDIO ? "SDIO" : "unknown");
}
cam_freeccb(ccb);
cam_close_device(dev);
return (0);
}

View File

@ -506,7 +506,6 @@ struct device_match_result {
struct scsi_inquiry_data inq_data;
struct ata_params ident_data;
dev_result_flags flags;
struct mmc_params mmc_ident_data;
};
struct bus_match_result {
@ -1278,6 +1277,7 @@ struct ccb_dev_advinfo {
#define CDAI_TYPE_EXT_INQ 5
#define CDAI_TYPE_NVME_CNTRL 6 /* NVMe Identify Controller data */
#define CDAI_TYPE_NVME_NS 7 /* NVMe Identify Namespace data */
#define CDAI_TYPE_MMC_PARAMS 8 /* MMC/SD ident */
off_t bufsiz; /* IN: Size of external buffer */
#define CAM_SCSI_DEVID_MAXLEN 65536 /* length in buffer is an uint16_t */
off_t provsiz; /* OUT: Size required/used */

View File

@ -1909,9 +1909,6 @@ xptedtdevicefunc(struct cam_ed *device, void *arg)
bcopy(&device->ident_data,
&cdm->matches[j].result.device_result.ident_data,
sizeof(struct ata_params));
bcopy(&device->mmc_ident_data,
&cdm->matches[j].result.device_result.mmc_ident_data,
sizeof(struct mmc_params));
/* Let the user know whether this device is unconfigured */
if (device->flags & CAM_DEV_UNCONFIGURED)

View File

@ -367,6 +367,13 @@ mmc_dev_advinfo(union ccb *start_ccb)
case CDAI_TYPE_PHYS_PATH: /* pass(4) wants this */
cdai->provsiz = 0;
break;
case CDAI_TYPE_MMC_PARAMS:
cdai->provsiz = device->mmc_ident_data;
if (device->mmc_ident_data == NULL)
break;
amt = MIN(cdai->provsiz, cdai->bufsiz);
memcpy(cdai->buff, device->mmc_ident_data, amt);
break;
default:
panic("Unknown buftype");
return;