From nobody Wed Jan 19 19:08:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8A231196D105; Wed, 19 Jan 2022 19:08:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JfFXj2pTkz4kPT; Wed, 19 Jan 2022 19:08:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642619301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5y/08bHQibuXhgFWTKs9daugsbS4hfx+lnB+NLY9jf0=; b=U6EH7WqqLDMNVvX2ipuYyzVHukwvTjN+wiDp7C04K7lJUFGv06N33rnyUmwGR6xpX1Pghi ZYNK1VJ/FXtuA33IbEEMIFQ4uLbJGX3+hcSCbUfLNrain1uSQn4DGHfeAypytMeCRbHMN0 j6MCiWErdhUVGuVFwvI6FdUQzy9T+C+5lAVJ54cNr9HVBEsvCwJwBW0ETMMj5kgjVHNNzn gjqxzKsdC7v1uQB0Pw6M45b6tTntFEWPQ7gyithq665gk2c/1TqbGBeJIPbe0Wvio26w0d cQeJllRSrWVAk1MoSVPa8auqTNlrfwS7wfGWin2aheUkPsMp/IrwBtbZmycHVA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38BF21A584; Wed, 19 Jan 2022 19:08:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20JJ8Ltr085093; Wed, 19 Jan 2022 19:08:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20JJ8LOq085092; Wed, 19 Jan 2022 19:08:21 GMT (envelope-from git) Date: Wed, 19 Jan 2022 19:08:21 GMT Message-Id: <202201191908.20JJ8LOq085092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 170a0a8ebbd3 - main - ses: minor cleanup List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 170a0a8ebbd386b024f7f4c017eb60ea2b9110f2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642619301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5y/08bHQibuXhgFWTKs9daugsbS4hfx+lnB+NLY9jf0=; b=DpF5qp78X513C8qgJe/NskfxkaiVq7ARwJP6YErl7G9Y6AmCpBKj/tERRPMXc5ntIBwGfF S7qp85lzYoQc56QXfEjwnjNFYc7bcMqJb2YQDHFCFXq0fUXcRCeqqptz0Ou+9ingvyzUyW 33/NvnHUv+pTNQuAWVS56V/gIH2WTgB0oZz+QP8Thz3+AzHZlpDqPHcHlNEvNddxnXt4yy p/POcH52nAkwowWHS3z7q+BNxtFTpa+0VR+ScC/JiuUQc0lotZkWNBP+kpdkWKzXlkjwCF WNkTX3XqnKWatouV0ZeliWQLBOVd1+0HcV8OxrRwdObga0/vgLhv9NP4lH1EnA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642619301; a=rsa-sha256; cv=none; b=H4S8F4OASdgsBead4ZWHIcCUFIVdjqHWls0E7E4zHMJGAMY1EwtWZF7RACmak+xXutJAlx 6eIs7PIgeV1yA1hL2NSuujt00o9ROw6ig4kGvMgvBj3mBUXU1jd+Rsj/NiOOGk25WjjAsm Ogdkv/2KeVuzyROTe5iryJP94OOWbl5t2uOl6ONBsvKlOLm0ZkJAKQrImUzFWEiT80Gmiv 0gxPekvkEiUKsIZ9ItW2QGwgwltI+Bn6c/Cr1ETBDE2+zcdNzkHh6RklvJc/zpUmpCoy+f /j/04j7n+RenXpas/uv8xY4sMkOSxEjhzCj5fsXWPgkIoYs4WN09B3rhtZLhvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=170a0a8ebbd386b024f7f4c017eb60ea2b9110f2 commit 170a0a8ebbd386b024f7f4c017eb60ea2b9110f2 Author: Alan Somers AuthorDate: 2021-08-25 21:08:19 +0000 Commit: Alan Somers CommitDate: 2022-01-19 19:08:03 +0000 ses: minor cleanup * Prefer variables of small scope rather than large scope * Remove a magic number * style(9) for return statements * Remove the get_enc_status method, which never did anything * Fix a variable type in the handle_string method * Proofread some comments MFC after: 2 weeks Sponsored by: Spectra Logic, Axcient Reviewed by: ken, mav Differential Revision: https://reviews.freebsd.org/D31686 --- sys/cam/scsi/scsi_enc.c | 54 ++++++++++++++++++++-------------------- sys/cam/scsi/scsi_enc.h | 16 ++++++------ sys/cam/scsi/scsi_enc_internal.h | 5 ++-- sys/cam/scsi/scsi_enc_safte.c | 8 ------ sys/cam/scsi/scsi_enc_ses.c | 14 +++-------- 5 files changed, 40 insertions(+), 57 deletions(-) diff --git a/sys/cam/scsi/scsi_enc.c b/sys/cam/scsi/scsi_enc.c index e01f613514fb..b8afdf938a3a 100644 --- a/sys/cam/scsi/scsi_enc.c +++ b/sys/cam/scsi/scsi_enc.c @@ -354,12 +354,6 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, struct thread *td) { struct cam_periph *periph; - encioc_enc_status_t tmp; - encioc_string_t sstr; - encioc_elm_status_t elms; - encioc_elm_desc_t elmd; - encioc_elm_devnames_t elmdn; - encioc_element_t *uelm; enc_softc_t *enc; enc_cache_t *cache; void *addr; @@ -436,7 +430,9 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, error = copyout(&cache->nelms, addr, sizeof (cache->nelms)); break; - case ENCIOC_GETELMMAP: + case ENCIOC_GETELMMAP: { + encioc_element_t *uelm; + for (uelm = addr, i = 0; i != cache->nelms; i++) { encioc_element_t kelm; kelm.elm_idx = i; @@ -447,21 +443,15 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, break; } break; - - case ENCIOC_GETENCSTAT: - cam_periph_lock(periph); - error = enc->enc_vec.get_enc_status(enc, 1); - if (error) { - cam_periph_unlock(periph); - break; - } - tmp = cache->enc_status; - cam_periph_unlock(periph); - error = copyout(&tmp, addr, sizeof(tmp)); - cache->enc_status = tmp; + } + case ENCIOC_GETENCSTAT: { + error = copyout(&cache->enc_status, addr, + sizeof(cache->enc_status)); break; + } + case ENCIOC_SETENCSTAT: { + encioc_enc_status_t tmp; - case ENCIOC_SETENCSTAT: error = copyin(addr, &tmp, sizeof(tmp)); if (error) break; @@ -469,11 +459,13 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, error = enc->enc_vec.set_enc_status(enc, tmp, 1); cam_periph_unlock(periph); break; - + } case ENCIOC_GETSTRING: case ENCIOC_SETSTRING: case ENCIOC_GETENCNAME: - case ENCIOC_GETENCID: + case ENCIOC_GETENCID: { + encioc_string_t sstr; + if (enc->enc_vec.handle_string == NULL) { error = EINVAL; break; @@ -489,8 +481,10 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, &((encioc_string_t *)addr)->bufsiz, sizeof(sstr.bufsiz)); break; + } + case ENCIOC_GETELMSTAT: { + encioc_elm_status_t elms; - case ENCIOC_GETELMSTAT: error = copyin(addr, &elms, sizeof(elms)); if (error) break; @@ -505,8 +499,10 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, break; error = copyout(&elms, addr, sizeof(elms)); break; + } + case ENCIOC_GETELMDESC: { + encioc_elm_desc_t elmd; - case ENCIOC_GETELMDESC: error = copyin(addr, &elmd, sizeof(elmd)); if (error) break; @@ -522,8 +518,10 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, elmd.elm_desc_len = 0; error = copyout(&elmd, addr, sizeof(elmd)); break; + } + case ENCIOC_GETELMDEVNAMES: { + encioc_elm_devnames_t elmdn; - case ENCIOC_GETELMDEVNAMES: if (enc->enc_vec.get_elm_devnames == NULL) { error = EINVAL; break; @@ -542,8 +540,10 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, break; error = copyout(&elmdn, addr, sizeof(elmdn)); break; + } + case ENCIOC_SETELMSTAT: { + encioc_elm_status_t elms; - case ENCIOC_SETELMSTAT: error = copyin(addr, &elms, sizeof(elms)); if (error) break; @@ -557,7 +557,7 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, cam_periph_unlock(periph); break; - + } case ENCIOC_INIT: cam_periph_lock(periph); diff --git a/sys/cam/scsi/scsi_enc.h b/sys/cam/scsi/scsi_enc.h index b816a6a5d4cd..f53a99f2b233 100644 --- a/sys/cam/scsi/scsi_enc.h +++ b/sys/cam/scsi/scsi_enc.h @@ -75,23 +75,23 @@ * * * An application finds out how many elements an enclosure instance - * is managing by performing a ENCIOC_GETNELM operation. It then - * performs a ENCIOC_GETELMMAP to get the map that contains the - * elment identifiers for all elements (see encioc_element_t below). + * manages by performing a ENCIOC_GETNELM operation. It then + * performs an ENCIOC_GETELMMAP to get the map that contains the + * element identifiers for all elements (see encioc_element_t below). * This information is static. * * The application may perform ENCIOC_GETELMSTAT operations to retrieve - * status on an element (see the enc_elm_status_t structure below), - * ENCIOC_SETELMSTAT operations to set status for an element. + * status on an element (see the encioc_elm_status_t structure below), + * and ENCIOC_SETELMSTAT operations to set status for an element. * - * Similarly, overall enclosure status me be fetched or set via - * ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t + * Similarly, overall enclosure status may be fetched or set via + * ENCIOC_GETENCSTAT or ENCIOC_SETENCSTAT operations (see encioc_enc_status_t * below). * * Readers should note that there is nothing that requires either a set * or a clear operation to actually latch and do anything in the target. * - * A ENCIOC_INIT operation causes the enclosure to be initialized. + * An ENCIOC_INIT operation causes the enclosure to be initialized. */ /* Element Types */ diff --git a/sys/cam/scsi/scsi_enc_internal.h b/sys/cam/scsi/scsi_enc_internal.h index cea5eebfeb5f..e57634d065df 100644 --- a/sys/cam/scsi/scsi_enc_internal.h +++ b/sys/cam/scsi/scsi_enc_internal.h @@ -88,13 +88,13 @@ typedef int (enc_softc_init_t)(enc_softc_t *); typedef void (enc_softc_invalidate_t)(enc_softc_t *); typedef void (enc_softc_cleanup_t)(enc_softc_t *); typedef int (enc_init_enc_t)(enc_softc_t *); -typedef int (enc_get_enc_status_t)(enc_softc_t *, int); typedef int (enc_set_enc_status_t)(enc_softc_t *, encioc_enc_status_t, int); typedef int (enc_get_elm_status_t)(enc_softc_t *, encioc_elm_status_t *, int); typedef int (enc_set_elm_status_t)(enc_softc_t *, encioc_elm_status_t *, int); typedef int (enc_get_elm_desc_t)(enc_softc_t *, encioc_elm_desc_t *); typedef int (enc_get_elm_devnames_t)(enc_softc_t *, encioc_elm_devnames_t *); -typedef int (enc_handle_string_t)(enc_softc_t *, encioc_string_t *, int); +typedef int (enc_handle_string_t)(enc_softc_t *, encioc_string_t *, + unsigned long); typedef void (enc_device_found_t)(enc_softc_t *); typedef void (enc_poll_status_t)(enc_softc_t *); @@ -102,7 +102,6 @@ struct enc_vec { enc_softc_invalidate_t *softc_invalidate; enc_softc_cleanup_t *softc_cleanup; enc_init_enc_t *init_enc; - enc_get_enc_status_t *get_enc_status; enc_set_enc_status_t *set_enc_status; enc_get_elm_status_t *get_elm_status; enc_set_elm_status_t *set_elm_status; diff --git a/sys/cam/scsi/scsi_enc_safte.c b/sys/cam/scsi/scsi_enc_safte.c index 200c32073644..7539531302f9 100644 --- a/sys/cam/scsi/scsi_enc_safte.c +++ b/sys/cam/scsi/scsi_enc_safte.c @@ -1023,13 +1023,6 @@ safte_init_enc(enc_softc_t *enc) return (err); } -static int -safte_get_enc_status(enc_softc_t *enc, int slpflg) -{ - - return (0); -} - static int safte_set_enc_status(enc_softc_t *enc, uint8_t encstat, int slpflag) { @@ -1101,7 +1094,6 @@ static struct enc_vec safte_enc_vec = .softc_invalidate = safte_softc_invalidate, .softc_cleanup = safte_softc_cleanup, .init_enc = safte_init_enc, - .get_enc_status = safte_get_enc_status, .set_enc_status = safte_set_enc_status, .get_elm_status = safte_get_elm_status, .set_elm_status = safte_set_elm_status, diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c index 803630f31f54..557038d9b9f6 100644 --- a/sys/cam/scsi/scsi_enc_ses.c +++ b/sys/cam/scsi/scsi_enc_ses.c @@ -744,7 +744,7 @@ ses_elm_addlstatus_proto(struct ses_elm_addlstatus_base_hdr *hdr) int ses_elm_addlstatus_eip(struct ses_elm_addlstatus_base_hdr *hdr) { - return ((hdr)->byte0 >> 4) & 0x1; + return ((hdr)->byte0 >> 4 & 0x1); } int ses_elm_addlstatus_invalid(struct ses_elm_addlstatus_base_hdr *hdr) @@ -2751,13 +2751,6 @@ ses_init_enc(enc_softc_t *enc) return (0); } -static int -ses_get_enc_status(enc_softc_t *enc, int slpflag) -{ - /* Automatically updated, caller checks enc_cache->encstat itself */ - return (0); -} - static int ses_set_enc_status(enc_softc_t *enc, uint8_t encstat, int slpflag) { @@ -2866,7 +2859,7 @@ ses_get_elm_devnames(enc_softc_t *enc, encioc_elm_devnames_t *elmdn) * \return 0 on success, errno otherwise. */ static int -ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, int ioc) +ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, unsigned long ioc) { enc_cache_t *enc_cache; ses_cache_t *ses_cache; @@ -2884,7 +2877,7 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, int ioc) ses_cache = enc_cache->private; /* Implement SES2r20 6.1.6 */ - if (sstr->bufsiz > 0xffff) + if (sstr->bufsiz > ENC_STRING_MAX) return (EINVAL); /* buffer size too large */ switch (ioc) { @@ -2993,7 +2986,6 @@ static struct enc_vec ses_enc_vec = .softc_invalidate = ses_softc_invalidate, .softc_cleanup = ses_softc_cleanup, .init_enc = ses_init_enc, - .get_enc_status = ses_get_enc_status, .set_enc_status = ses_set_enc_status, .get_elm_status = ses_get_elm_status, .set_elm_status = ses_set_elm_status,