From nobody Tue Aug 01 22:26:12 2023 X-Original-To: dev-commits-src-main@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 4RFqTQ1RCpz4pwpK; Tue, 1 Aug 2023 22:26:20 +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 4RFqT03gVXz3hXZ; Tue, 1 Aug 2023 22:26:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690928772; 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=cIbZCzaUw73bM4H0ibcXhtJiGLnI/0Cx1ixeaRhV8f0=; b=RkrYBpHx/7FdtvMudhsjq5LEo2Y/bjrSnB6Q68mNfHB3Vo6o+7SR76306LThxTGlzu95oL jwUdEcJG/+UK9li2NrwM3Awlrj9V16TEn1iOWyO66sYgDpFVZfqDs0Q1tEl10wbxrH53Ex 2QmTDokmRsAf+Vcf6DlY/ByEVXu8I4kPWpCSjifaAcYrp1WI72ZTXpnRXebduztwvkMBCu xyQ5VcrRErc2HR2L/mw9p+ten7ww3RaXKJ5Znlrd+bJFj6xu4Q5GRSwcHMCgFbz6ylUYHW 5l0cCd9eaSSRzePD9dBavzxQm/EPNuVK2opiKGmJTYfkprxNT+eoydWNXbgc5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690928772; a=rsa-sha256; cv=none; b=JQep92uNUhMPu/cOHUsfeVx9+rxSrjIoGALJe6PvbhuYNU/QmdB2qBj6Dk3FgaiRabXHiI NpPVJVf8oEa4NLwQ1wTJM+wVh95cOhkBBU3bWJG/rwjPeq8fZw/LhyAkggvSbmY5wVNZLe LMGmimcqSCuUy4KAJX1kkkJDe8Xz8poXAi/74b07EsNFK49PKAB72t1zQkaJevSTwTwsaL mUq+4By2xeOCGRXPURtTvuJ5KdOHHs2HETEfkyKlJDElFwg1PT22KrRkk/0qFp4b5LQWNm dLOYpFHVRgfBYA232EngJ271DlI/jiSv694/Lq0GGtp/23RTQ4eMKdXZ7pl8Gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690928772; 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=cIbZCzaUw73bM4H0ibcXhtJiGLnI/0Cx1ixeaRhV8f0=; b=COWwSgQeG58nuUicwiITq/Z96uYJmd2GXJXJ97KEAGBqNbDN+LFZcohaXgWWilG951amSZ 8byauB6lXgPpAJ/pc+CRnBIvW41J6eKn6Vt/3gp3aoagNXTPhQEt8POAFmvJLkkODm2/ir C7/UdPan3h1PO9jX2iOkfvtCXWkrzJD+fCVIJ+1t4nNFlTMNwMeozYPQhfr+UIftBEE6Ia Qx6JBLj++614Wy8znkaSXxGwWQT4tbI5GrMLHzcNXQgnVTSy8EBgDgCgkNwDNwsEDcSQLr O8YZSPtszJD5s4f1WGbB+yus0kZv+aJwQs8pWn7VGv6ij7gxnUO0MJqZtXKfsQ== 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 4RFqT02TgNzvd9; Tue, 1 Aug 2023 22:26:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 371MQCOn045647; Tue, 1 Aug 2023 22:26:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 371MQC5D045646; Tue, 1 Aug 2023 22:26:12 GMT (envelope-from git) Date: Tue, 1 Aug 2023 22:26:12 GMT Message-Id: <202308012226.371MQC5D045646@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 0a57cdd971b2 - main - cam_xpt: Reimplement xpt_*nounce_periph in terms of the _sbuf versions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a57cdd971b24292c48e3a0be08ba5ebf0b54a31 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=0a57cdd971b24292c48e3a0be08ba5ebf0b54a31 commit 0a57cdd971b24292c48e3a0be08ba5ebf0b54a31 Author: John Baldwin AuthorDate: 2023-08-01 22:24:36 +0000 Commit: John Baldwin CommitDate: 2023-08-01 22:24:36 +0000 cam_xpt: Reimplement xpt_*nounce_periph in terms of the _sbuf versions Use an sbuf that drains to printf to avoid duplicating code in the two versions of each function. Reviewed by: mav Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D41263 --- sys/cam/cam_xpt.c | 68 ++++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 56 deletions(-) diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index e7248cf76d19..6ff8a61457fa 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1045,43 +1045,13 @@ xpt_remove_periph(struct cam_periph *periph) void xpt_announce_periph(struct cam_periph *periph, char *announce_string) { - struct cam_path *path = periph->path; - struct xpt_proto *proto; - - cam_periph_assert(periph, MA_OWNED); - periph->flags |= CAM_PERIPH_ANNOUNCED; + char buf[128]; + struct sbuf sb; - printf("%s%d at %s%d bus %d scbus%d target %d lun %jx\n", - periph->periph_name, periph->unit_number, - path->bus->sim->sim_name, - path->bus->sim->unit_number, - path->bus->sim->bus_id, - path->bus->path_id, - path->target->target_id, - (uintmax_t)path->device->lun_id); - printf("%s%d: ", periph->periph_name, periph->unit_number); - proto = xpt_proto_find(path->device->protocol); - if (proto) - proto->ops->announce(path->device); - else - printf("Unknown protocol device %d\n", path->device->protocol); - if (path->device->serial_num_len > 0) { - /* Don't wrap the screen - print only the first 60 chars */ - printf("%s%d: Serial Number %.60s\n", periph->periph_name, - periph->unit_number, path->device->serial_num); - } - /* Announce transport details. */ - path->bus->xport->ops->announce(periph); - /* Announce command queueing. */ - if (path->device->inq_flags & SID_CmdQue - || path->device->flags & CAM_DEV_TAG_AFTER_COUNT) { - printf("%s%d: Command Queueing enabled\n", - periph->periph_name, periph->unit_number); - } - /* Announce caller's details if they've passed in. */ - if (announce_string != NULL) - printf("%s%d: %s\n", periph->periph_name, - periph->unit_number, announce_string); + (void)sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL); + sbuf_set_drain(&sb, sbuf_printf_drain, NULL); + xpt_announce_periph_sbuf(periph, &sb, announce_string); + (void)sbuf_finish(&sb); } void @@ -1151,27 +1121,13 @@ xpt_announce_quirks_sbuf(struct cam_periph *periph, struct sbuf *sb, void xpt_denounce_periph(struct cam_periph *periph) { - struct cam_path *path = periph->path; - struct xpt_proto *proto; + char buf[128]; + struct sbuf sb; - cam_periph_assert(periph, MA_OWNED); - printf("%s%d at %s%d bus %d scbus%d target %d lun %jx\n", - periph->periph_name, periph->unit_number, - path->bus->sim->sim_name, - path->bus->sim->unit_number, - path->bus->sim->bus_id, - path->bus->path_id, - path->target->target_id, - (uintmax_t)path->device->lun_id); - printf("%s%d: ", periph->periph_name, periph->unit_number); - proto = xpt_proto_find(path->device->protocol); - if (proto) - proto->ops->denounce(path->device); - else - printf("Unknown protocol device %d", path->device->protocol); - if (path->device->serial_num_len > 0) - printf(" s/n %.60s", path->device->serial_num); - printf(" detached\n"); + (void)sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL); + sbuf_set_drain(&sb, sbuf_printf_drain, NULL); + xpt_denounce_periph_sbuf(periph, &sb); + (void)sbuf_finish(&sb); } void