Date: Thu, 8 Aug 2019 02:11:42 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350724 - in stable/12/sys/cam: ata scsi Message-ID: <201908080211.x782BgjP029318@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Thu Aug 8 02:11:42 2019 New Revision: 350724 URL: https://svnweb.freebsd.org/changeset/base/350724 Log: MFC r349340 (by imp): Create ata_param_fixup Create a common fixup routine to do the canonical fixup of the ata_param fixup. Call it from both the ATA and the ATA over SCSI paths. Modified: stable/12/sys/cam/ata/ata_all.c stable/12/sys/cam/ata/ata_all.h stable/12/sys/cam/ata/ata_xpt.c stable/12/sys/cam/scsi/scsi_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ata/ata_all.c ============================================================================== --- stable/12/sys/cam/ata/ata_all.c Thu Aug 8 02:11:08 2019 (r350723) +++ stable/12/sys/cam/ata/ata_all.c Thu Aug 8 02:11:42 2019 (r350724) @@ -1238,3 +1238,28 @@ ata_zac_mgmt_in(struct ccb_ataio *ataio, uint32_t retr ataio->aux = auxiliary; } } + +void +ata_param_fixup(struct ata_params *ident_buf) +{ + int16_t *ptr; + + for (ptr = (int16_t *)ident_buf; + ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { + *ptr = le16toh(*ptr); + } + if (strncmp(ident_buf->model, "FX", 2) && + strncmp(ident_buf->model, "NEC", 3) && + strncmp(ident_buf->model, "Pioneer", 7) && + strncmp(ident_buf->model, "SHARP", 5)) { + ata_bswap(ident_buf->model, sizeof(ident_buf->model)); + ata_bswap(ident_buf->revision, sizeof(ident_buf->revision)); + ata_bswap(ident_buf->serial, sizeof(ident_buf->serial)); + } + ata_btrim(ident_buf->model, sizeof(ident_buf->model)); + ata_bpack(ident_buf->model, ident_buf->model, sizeof(ident_buf->model)); + ata_btrim(ident_buf->revision, sizeof(ident_buf->revision)); + ata_bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision)); + ata_btrim(ident_buf->serial, sizeof(ident_buf->serial)); + ata_bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial)); +} Modified: stable/12/sys/cam/ata/ata_all.h ============================================================================== --- stable/12/sys/cam/ata/ata_all.h Thu Aug 8 02:11:08 2019 (r350723) +++ stable/12/sys/cam/ata/ata_all.h Thu Aug 8 02:11:42 2019 (r350724) @@ -135,6 +135,7 @@ void ata_read_log(struct ccb_ataio *ataio, uint32_t re uint16_t block_count, uint32_t protocol, uint8_t *data_ptr, uint32_t dxfer_len, uint32_t timeout); +void ata_param_fixup(struct ata_params *ident_buf); void ata_bswap(int8_t *buf, int len); void ata_btrim(int8_t *buf, int len); void ata_bpack(int8_t *src, int8_t *dst, int len); Modified: stable/12/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/12/sys/cam/ata/ata_xpt.c Thu Aug 8 02:11:08 2019 (r350723) +++ stable/12/sys/cam/ata/ata_xpt.c Thu Aug 8 02:11:42 2019 (r350724) @@ -893,31 +893,13 @@ noerror: case PROBE_IDENTIFY: { struct ccb_pathinq cpi; - int16_t *ptr; int veto = 0; /* * Convert to host byte order, and fix the strings. */ ident_buf = &softc->ident_data; - for (ptr = (int16_t *)ident_buf; - ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { - *ptr = le16toh(*ptr); - } - if (strncmp(ident_buf->model, "FX", 2) && - strncmp(ident_buf->model, "NEC", 3) && - strncmp(ident_buf->model, "Pioneer", 7) && - strncmp(ident_buf->model, "SHARP", 5)) { - ata_bswap(ident_buf->model, sizeof(ident_buf->model)); - ata_bswap(ident_buf->revision, sizeof(ident_buf->revision)); - ata_bswap(ident_buf->serial, sizeof(ident_buf->serial)); - } - ata_btrim(ident_buf->model, sizeof(ident_buf->model)); - ata_bpack(ident_buf->model, ident_buf->model, sizeof(ident_buf->model)); - ata_btrim(ident_buf->revision, sizeof(ident_buf->revision)); - ata_bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision)); - ata_btrim(ident_buf->serial, sizeof(ident_buf->serial)); - ata_bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial)); + ata_param_fixup(ident_buf); /* * Allow others to veto this ATA disk attachment. This Modified: stable/12/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/12/sys/cam/scsi/scsi_da.c Thu Aug 8 02:11:08 2019 (r350723) +++ stable/12/sys/cam/scsi/scsi_da.c Thu Aug 8 02:11:42 2019 (r350724) @@ -5174,7 +5174,7 @@ dadone_probeata(struct cam_periph *periph, union ccb * struct da_softc *softc; u_int32_t priority; int continue_probe; - int error, i; + int error; int16_t *ptr; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeata\n")); @@ -5192,8 +5192,7 @@ dadone_probeata(struct cam_periph *periph, union ccb * if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { uint16_t old_rate; - for (i = 0; i < sizeof(*ata_params) / 2; i++) - ptr[i] = le16toh(ptr[i]); + ata_param_fixup(ata_params); if (ata_params->support_dsm & ATA_SUPPORT_DSM_TRIM && (softc->quirks & DA_Q_NO_UNMAP) == 0) { dadeleteflag(softc, DA_DELETE_ATA_TRIM, 1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908080211.x782BgjP029318>