From patchwork Mon Oct 2 16:16:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406456 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 559261DA3E for ; Mon, 2 Oct 2023 16:18:53 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84587B3; Mon, 2 Oct 2023 09:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263531; x=1727799531; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wKIv3sJ1clYjdqjwiVvVRD9CCUCGlQHTF5I50Li2+CE=; b=YQUCYh+FujSv3BhhaOmeakFbdUAU+jnOEeWihojYFtNu2RSRdMHSSEZ4 ySGVsIVmpr3JHAdngGVz9OeYgwpQ0cAMBVJRzpksJZtUFu7xViO+ooOFA d8PLSDXZEzHptzYIrqto1fOE5iJfgcI1zdtTykL9Jkcd6racFo7iFn8FN sFJ2lg6J5NlIGbH3FtnkaCOw3pFVW275PDaLAjQzcNqzpeX8Ux5Zc8Img v2d2CnsYtV9Y+8t+IFYUMAgpfKWmTgGb8LpaC4LolnKVAa9p5sNbrergz jPjGkCgkIY9x6pQ5fMMF5+961zGR4GCbaOl/cWqVn3dufFBSxGi6qaSRF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362949518" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362949518" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="816339772" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="816339772" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Oct 2023 09:16:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1B2D81A7; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 01/10] xhci: dbc: Drop duplicate checks for dma_free_coherent() Date: Mon, 2 Oct 2023 19:16:01 +0300 Message-Id: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net dma_free_coherent() is NULL-aware, not necessary to check for the parameter twice. Drop duplicate conditionals in the caller. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index b40d9238d447..9e9ce3711813 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -28,7 +28,7 @@ static void dbc_ring_free(struct device *dev, struct xhci_ring *ring) if (!ring) return; - if (ring->first_seg && ring->first_seg->trbs) { + if (ring->first_seg) { dma_free_coherent(dev, TRB_SEGMENT_SIZE, ring->first_seg->trbs, ring->first_seg->dma); @@ -394,9 +394,8 @@ static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, static void dbc_erst_free(struct device *dev, struct xhci_erst *erst) { - if (erst->entries) - dma_free_coherent(dev, sizeof(struct xhci_erst_entry), - erst->entries, erst->erst_dma_addr); + dma_free_coherent(dev, sizeof(struct xhci_erst_entry), erst->entries, + erst->erst_dma_addr); erst->entries = NULL; } @@ -543,11 +542,8 @@ static void xhci_dbc_mem_cleanup(struct xhci_dbc *dbc) xhci_dbc_eps_exit(dbc); - if (dbc->string) { - dma_free_coherent(dbc->dev, dbc->string_size, - dbc->string, dbc->string_dma); - dbc->string = NULL; - } + dma_free_coherent(dbc->dev, dbc->string_size, dbc->string, dbc->string_dma); + dbc->string = NULL; dbc_free_ctx(dbc->dev, dbc->ctx); dbc->ctx = NULL; From patchwork Mon Oct 2 16:16:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406460 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9403E1DA34 for ; Mon, 2 Oct 2023 16:19:14 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE5BCD6; Mon, 2 Oct 2023 09:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263548; x=1727799548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5wFq2LWIAxkbz3owrFJUzWLLHVZI7rE5EIksKjGKEtQ=; b=PpFW3mKAiAIUu2fzvk8U0OGsGAiZ1zEf0lfKQdCsCXM/SvSOawp4DSSm gBr0CkqT9xF/MMkhcnaQHit8mha54gqe+6ArH+fpaPycYhX9Osk6raeMP LfQP62lcRDkFspccQpxX14dkVHTGIIZDB3lD727ML9hp2u3oKf5YjIfi1 PUS4C7UuRhmV3U52uneuKxZwLsbOXPg/vNqijZu6u9/xCzV+DkBN5CTpS xt1kWslJIJFQQ8zmgPIOlh1apUK5icYWqzgBXc2EZqhjVOqrqtZYzuZUz blcC/29iGAdPU16Z/nV7ff3d8xvLXfqmJFvcTailbg/q65fSYjppj5dkX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="382588645" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="382588645" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="841031505" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="841031505" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Oct 2023 09:16:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2AAC894; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 02/10] xhci: dbc: Convert to use sysfs_streq() Date: Mon, 2 Oct 2023 19:16:02 +0300 Message-Id: <20231002161610.2648818-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net It's standard approach to parse values from user space by using sysfs_streq(). Make driver use it. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 9e9ce3711813..f505b79afe53 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -957,9 +957,9 @@ static ssize_t dbc_store(struct device *dev, xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; - if (!strncmp(buf, "enable", 6)) + if (sysfs_streq(buf, "enable")) xhci_dbc_start(dbc); - else if (!strncmp(buf, "disable", 7)) + else if (sysfs_streq(buf, "disable")) xhci_dbc_stop(dbc); else return -EINVAL; From patchwork Mon Oct 2 16:16:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406454 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E68EC1A711 for ; Mon, 2 Oct 2023 16:18:51 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0559493; Mon, 2 Oct 2023 09:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263529; x=1727799529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CY4OM5esL8i/3kUHybBmDSjRpzOpgGo+r8iIQDCl14A=; b=BDKy8ml9CK0ISKHn6ltB8qkcW1vsU4Lb6LFS4B/NJ1JHTBfXzHLEmA8a HCyOfrm1fvCVwd88SyK9xDq0KR7/KnxE0VrnAUgIxuamPkAfpuT6TUkbP qWY6/AQhR5mPVd4mFETgcX6XISHZ5M0cXpPm4A86+6K5GXm2QkxRWKo2C NkhAnn8r6gSxeDfQ0TSDxkWHqJX7Jk3zlDILrfpyPd9oCH+bNqJ5cZEVi 0PJD306z4UUOGfSRJOi36jdNt1B8EZfQYvXDrHwbqKmoSKqTy5e6auMqa QlRJiG/tpnt2et69ieBWaTaQJo2vapNYdq67d2YfPDVYlAVbheUtUPNAx A==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362949511" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362949511" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="816339768" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="816339768" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Oct 2023 09:16:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3069B2FF; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 03/10] xhci: dbc: Use sysfs_emit() to instead of scnprintf() Date: Mon, 2 Oct 2023 19:16:03 +0300 Message-Id: <20231002161610.2648818-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 43 +++++++++++++--------------------- drivers/usb/host/xhci-dbgcap.h | 1 + 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index f505b79afe53..92869c67a430 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -910,6 +910,15 @@ static void xhci_dbc_handle_events(struct work_struct *work) mod_delayed_work(system_wq, &dbc->event_work, 1); } +static const char * const dbc_state_strings[DS_MAX] = { + [DS_DISABLED] = "disabled", + [DS_INITIALIZED] = "initialized", + [DS_ENABLED] = "enabled", + [DS_CONNECTED] = "connected", + [DS_CONFIGURED] = "configured", + [DS_STALLED] = "stalled", +}; + static ssize_t dbc_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -921,30 +930,10 @@ static ssize_t dbc_show(struct device *dev, xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; - switch (dbc->state) { - case DS_DISABLED: - p = "disabled"; - break; - case DS_INITIALIZED: - p = "initialized"; - break; - case DS_ENABLED: - p = "enabled"; - break; - case DS_CONNECTED: - p = "connected"; - break; - case DS_CONFIGURED: - p = "configured"; - break; - case DS_STALLED: - p = "stalled"; - break; - default: - p = "unknown"; - } + if (dbc->state >= ARRAY_SIZE(dbc_state_strings)) + return sysfs_emit(buf, "unknown\n"); - return sprintf(buf, "%s\n", p); + return sysfs_emit(buf, "%s\n", dbc_state_strings[dbc->state]); } static ssize_t dbc_store(struct device *dev, @@ -977,7 +966,7 @@ static ssize_t dbc_idVendor_show(struct device *dev, xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; - return sprintf(buf, "%04x\n", dbc->idVendor); + return sysfs_emit(buf, "%04x\n", dbc->idVendor); } static ssize_t dbc_idVendor_store(struct device *dev, @@ -1017,7 +1006,7 @@ static ssize_t dbc_idProduct_show(struct device *dev, xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; - return sprintf(buf, "%04x\n", dbc->idProduct); + return sysfs_emit(buf, "%04x\n", dbc->idProduct); } static ssize_t dbc_idProduct_store(struct device *dev, @@ -1056,7 +1045,7 @@ static ssize_t dbc_bcdDevice_show(struct device *dev, xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; - return sprintf(buf, "%04x\n", dbc->bcdDevice); + return sysfs_emit(buf, "%04x\n", dbc->bcdDevice); } static ssize_t dbc_bcdDevice_store(struct device *dev, @@ -1096,7 +1085,7 @@ static ssize_t dbc_bInterfaceProtocol_show(struct device *dev, xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; - return sprintf(buf, "%02x\n", dbc->bInterfaceProtocol); + return sysfs_emit(buf, "%02x\n", dbc->bInterfaceProtocol); } static ssize_t dbc_bInterfaceProtocol_store(struct device *dev, diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 51a7ab3ba0ca..e39e3ae1677a 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -82,6 +82,7 @@ enum dbc_state { DS_CONNECTED, DS_CONFIGURED, DS_STALLED, + DS_MAX }; struct dbc_ep { From patchwork Mon Oct 2 16:16:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406457 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B7EA1DA4A for ; Mon, 2 Oct 2023 16:18:54 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2EE3B8; Mon, 2 Oct 2023 09:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263532; x=1727799532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eRA4GqvkNOBVpjjvvEdbopHkDW3aOk0+GBRNEkvgsAo=; b=G1fIu1hhfcADQxKgfkynBKRfq+2e4cZy0Ubt4ddWPl+k4D47VmTRrXK0 9ntkl/9cbwl0dO31bLI2BRmT+vmrZ5SvlXFzh9hqCCteKZCWriWwGTJ8D glaw1rvpuXZmt7/hFPQ7wWhTNskyOH4psjhTaC2pr+qTFbVgHCYqAt1Jp bZgdUKdzJoXcbHfTWJXJdGesXx89JgLnTdxSN1CYUranIpyfG5QDS7Rjf ezwVD/4fENpjbC80PYAmt01lLW/vOQgw1z6d3BpYhSfTKlegPQN0nihUU RFGUozQe4QcV5Vh3mahIsbPvt4a3kdroYDIEm7TX5lsgy90JdJ62HaZKg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362949520" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362949520" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="816339773" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="816339773" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Oct 2023 09:16:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 38D77345; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 04/10] xhci: dbc: Use ATTRIBUTE_GROUPS() Date: Mon, 2 Oct 2023 19:16:04 +0300 Message-Id: <20231002161610.2648818-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Embrace ATTRIBUTE_GROUPS() to avoid boiler plate code. This should not introduce any functional changes. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 92869c67a430..3c90410e9cde 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -1124,7 +1124,7 @@ static DEVICE_ATTR_RW(dbc_idProduct); static DEVICE_ATTR_RW(dbc_bcdDevice); static DEVICE_ATTR_RW(dbc_bInterfaceProtocol); -static struct attribute *dbc_dev_attributes[] = { +static struct attribute *dbc_dev_attrs[] = { &dev_attr_dbc.attr, &dev_attr_dbc_idVendor.attr, &dev_attr_dbc_idProduct.attr, @@ -1132,10 +1132,7 @@ static struct attribute *dbc_dev_attributes[] = { &dev_attr_dbc_bInterfaceProtocol.attr, NULL }; - -static const struct attribute_group dbc_dev_attrib_grp = { - .attrs = dbc_dev_attributes, -}; +ATTRIBUTE_GROUPS(dbc_dev); struct xhci_dbc * xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver *driver) @@ -1161,7 +1158,7 @@ xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver * INIT_DELAYED_WORK(&dbc->event_work, xhci_dbc_handle_events); spin_lock_init(&dbc->lock); - ret = sysfs_create_group(&dev->kobj, &dbc_dev_attrib_grp); + ret = sysfs_create_groups(&dev->kobj, &dbc_dev_groups); if (ret) goto err; @@ -1180,7 +1177,7 @@ void xhci_dbc_remove(struct xhci_dbc *dbc) xhci_dbc_stop(dbc); /* remove sysfs files */ - sysfs_remove_group(&dbc->dev->kobj, &dbc_dev_attrib_grp); + sysfs_remove_groups(&dbc->dev->kobj, &dbc_dev_groups); kfree(dbc); } From patchwork Mon Oct 2 16:16:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406455 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE0071DA34 for ; Mon, 2 Oct 2023 16:18:52 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5E549E; Mon, 2 Oct 2023 09:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263530; x=1727799530; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XhexIisAVKWahtWglpDt4hA3GcZPi6mztI8CxfJXXLo=; b=mpbI92o1F0vBH6TzmoruAHDR9PjY1ZGFByAbN+5dPXQ11bv2RaE0SGyj wi5LXaNXPfyXval2Kl7GV2txNcfoS92aih0QqoqbmO8NKpmDgKaIzU+2t W9aBZH6UmJfVoy3uOStc4S38g6fSo4LI2Z13ehYiFGmHUs4XGLQQlNf8O kqzbok6OUBeZnNb1MXCfAHBFp26iOWuLlhRCqHFYyIglwEFww22pWraBq 2BfGInaf6PrI1Bon7NcTvZjKGU00UMCXfh5ddyGOIHuVYMUMKPcSW3lN/ P9971Q+hosupLLhyWuOLr5it2y7CshVFTL0wlN5D3rsI0k1k+enEOAdn2 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362949514" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362949514" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="816339774" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="816339774" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Oct 2023 09:16:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 47CFD14AF; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 05/10] xhci: dbc: Check for errors first in xhci_dbc_stop() Date: Mon, 2 Oct 2023 19:16:05 +0300 Message-Id: <20231002161610.2648818-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net The usual patter is to check for errors and then continue if none. Apply that pattern to xhci_dbc_stop() code. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 3c90410e9cde..d110eb5f1625 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -646,11 +646,11 @@ static void xhci_dbc_stop(struct xhci_dbc *dbc) spin_lock_irqsave(&dbc->lock, flags); ret = xhci_do_dbc_stop(dbc); spin_unlock_irqrestore(&dbc->lock, flags); + if (ret) + return; - if (!ret) { - xhci_dbc_mem_cleanup(dbc); - pm_runtime_put_sync(dbc->dev); /* note, was self.controller */ - } + xhci_dbc_mem_cleanup(dbc); + pm_runtime_put_sync(dbc->dev); /* note, was self.controller */ } static void From patchwork Mon Oct 2 16:16:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406462 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 664B61D527 for ; Mon, 2 Oct 2023 16:19:23 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33F311A7; Mon, 2 Oct 2023 09:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263554; x=1727799554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FrSE8d9uGldutiXJrJfF6BIwxKeDJqqgKYwSnq784UY=; b=l7/7K5U/A7+Zzi6F+US7ak70dSKo74HDpKCIoCDfplnxdvsyIDpmIvOf eflvmkCkcNxVFuZmpIFXbJ4XTdKAlEfidqoDyhMc/PDTC02twT8a3lMNB ZtePDdbWVAiEZiRiViSDkGLHw4rlIxtOvQlinHNl9eYNJa2GpigVP0ibs 1gdnJFFRlQWq8knoG3eoBIZm9P/RFEHzDQQCYaPJ3hHq3lZaQP9N/UDtz 4pleQG3gu3ua/fiZ4J61T7bB61EBFzNhI6tBL1cRIM5m59sL30MDYlPE0 UWj2CeVj84nDN+rnQiXSFNdVxJH5tiVU0Su68r1OSZzM8NI7xHQAyf+UA g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="382588658" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="382588658" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="841031516" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="841031516" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Oct 2023 09:16:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5C2FE157E; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 06/10] xhci: dbc: Don't shadow error codes in store() functions Date: Mon, 2 Oct 2023 19:16:06 +0300 Message-Id: <20231002161610.2648818-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net kstrtox() along with regmap API can return different error codes based on the circumstances. Don't shadow them when returning to the caller. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index d110eb5f1625..2332133c6581 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -978,9 +978,11 @@ static ssize_t dbc_idVendor_store(struct device *dev, void __iomem *ptr; u16 value; u32 dev_info; + int ret; - if (kstrtou16(buf, 0, &value)) - return -EINVAL; + ret = kstrtou16(buf, 0, &value); + if (ret) + return ret; xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; @@ -1018,9 +1020,11 @@ static ssize_t dbc_idProduct_store(struct device *dev, void __iomem *ptr; u32 dev_info; u16 value; + int ret; - if (kstrtou16(buf, 0, &value)) - return -EINVAL; + ret = kstrtou16(buf, 0, &value); + if (ret) + return ret; xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; @@ -1057,9 +1061,11 @@ static ssize_t dbc_bcdDevice_store(struct device *dev, void __iomem *ptr; u32 dev_info; u16 value; + int ret; - if (kstrtou16(buf, 0, &value)) - return -EINVAL; + ret = kstrtou16(buf, 0, &value); + if (ret) + return ret; xhci = hcd_to_xhci(dev_get_drvdata(dev)); dbc = xhci->dbc; @@ -1099,9 +1105,13 @@ static ssize_t dbc_bInterfaceProtocol_store(struct device *dev, u8 value; int ret; - /* bInterfaceProtocol is 8 bit, but xhci only supports values 0 and 1 */ + /* bInterfaceProtocol is 8 bit, but... */ ret = kstrtou8(buf, 0, &value); - if (ret || value > 1) + if (ret) + return ret; + + /* ...xhci only supports values 0 and 1 */ + if (value > 1) return -EINVAL; xhci = hcd_to_xhci(dev_get_drvdata(dev)); From patchwork Mon Oct 2 16:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406461 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 667E51DA36 for ; Mon, 2 Oct 2023 16:19:16 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E0D8CDE; Mon, 2 Oct 2023 09:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263549; x=1727799549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5q/ryLz/eJWv6HpUt5GYTqF30dvGM85K4SmBspi369M=; b=WeMv0O/wOILo+u+wWmbAWweKoGXVuIAvQ1/4uPIow4morT9Ttydha9ka atMEBrs220fhIp+kCOjRAb+/Y1pF2F++0IU0V54lfxnrK0aevlOsdJUMc GRGrr5o/SYFQKsThLm6k22WsF+aaJ6oL/RCH0mEuncsufL3XLQM1KfN8E KAa337IL3wVLq9aMZvgiEy6GhPNkT2/e99yicJ5+A564t7f2pgaeJhT+d FPWzfmPuGoJoh9MP2cJUVCeRH4tF403nVscm57LYID3fwVAY9HEfeUgBZ rNoIymHQuNOltoSnWKVSV7MTVGQUqDfHai0R27B8S2yn7zYHvXJfubR7Q g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="382588661" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="382588661" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="841031518" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="841031518" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Oct 2023 09:16:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6600614B3; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 07/10] xhci: dbc: Replace custom return value with proper Linux error code Date: Mon, 2 Oct 2023 19:16:07 +0300 Message-Id: <20231002161610.2648818-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Replace the custom return value with proper Linux error code. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 2332133c6581..617d057aa5f8 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -593,7 +593,7 @@ static int xhci_do_dbc_start(struct xhci_dbc *dbc) static int xhci_do_dbc_stop(struct xhci_dbc *dbc) { if (dbc->state == DS_DISABLED) - return -1; + return -EINVAL; writel(0, &dbc->regs->control); dbc->state = DS_DISABLED; From patchwork Mon Oct 2 16:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406459 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C79D61A711 for ; Mon, 2 Oct 2023 16:18:54 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0792BC4; Mon, 2 Oct 2023 09:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263533; x=1727799533; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kv1vxuF0jud+8jhw5JHU/tzaPQgxkHf1HRU7hzDONZc=; b=cWsw52IET/wE4wODSbhI5NS3NxwWOMFyvQNsHGpCZ/xHO6YmLjvES5Az SI0NLWHmkDNA/hF4VCza0BLhQ0SXbw5SgXyZMNGZkfUypbff6xRSMTQwj WSaTHyrjbL9nXfVqUHKTGuacaUqruordrEPMQDm+giYqK4cPfjOdKVahD lPHkU0+PDpIt3/rbP+KW4OAlAmjvY7+i3wOwzPc1/SqJ6wB/OpbBVHDz/ mATXAHQ5iiA09MAuEjDtQB/xLkW13mjrTbCLJeXlq2Tcg6CnAXacQzYkp cQOWfpn7xtrZ4ovcGCiJeHkCjwYt1sjaalS6nR0TA0qwjfUM5Hnbz1wrS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362949546" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362949546" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="816339812" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="816339812" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Oct 2023 09:16:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7551315BA; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 08/10] xhci: dbc: Use sizeof_field() where it makes sense Date: Mon, 2 Oct 2023 19:16:08 +0300 Message-Id: <20231002161610.2648818-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Instead of doing custom calculations, use sizeof_field() macro. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 617d057aa5f8..88e90c30916c 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -374,7 +374,7 @@ static void xhci_dbc_eps_init(struct xhci_dbc *dbc) static void xhci_dbc_eps_exit(struct xhci_dbc *dbc) { - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); } static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, From patchwork Mon Oct 2 16:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406463 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 365591DA36 for ; Mon, 2 Oct 2023 16:19:24 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A38F91B2; Mon, 2 Oct 2023 09:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263554; x=1727799554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XIwDvhcLk2v02GLDwaCD9wqDMTdN2dYVtBOJfYJ9NN4=; b=Sca32JuCzuVJWhJO5+Kezum95O6TMAQrdKTUuiTlZ5nL8833nplxOEQw Q1BjnbentWUDyObz98qjfRkgG381BIfr4v+EUsE5uGWyDUgCwzdVzdqoO 7eXe8g/I2epAha8oRY7MqPSsHt4RyUSKYTZ/1AJkvc/UNnS2u0OAPKlYY p7oVyE19SjBpxKh8rxwa41sj+/5ZeRd7Ijk4vtHm9QY6g+6HR1FCYPj0i sRPLdkGxmh+W+Hv8sasSwbLAWonWSAtBEDVJFvGeboj6QBFGGlapP9YAw O896hfnDImev1O8e9J8Ejsf/BcVvke4J8c3zAMeu9uAjrF4tkKl9pWKSB g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="382588666" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="382588666" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="841031520" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="841031520" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Oct 2023 09:16:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7AB291593; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 09/10] xhci: dbc: Use sizeof(*pointer) instead of sizeof(type) Date: Mon, 2 Oct 2023 19:16:09 +0300 Message-Id: <20231002161610.2648818-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net It is preferred to use sizeof(*pointer) instead of sizeof(type). The type of the variable can change and one needs not change the former (unlike the latter). No functional change intended. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 88e90c30916c..366ce3146a93 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -380,7 +380,7 @@ static void xhci_dbc_eps_exit(struct xhci_dbc *dbc) static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, struct xhci_erst *erst, gfp_t flags) { - erst->entries = dma_alloc_coherent(dev, sizeof(struct xhci_erst_entry), + erst->entries = dma_alloc_coherent(dev, sizeof(*erst->entries), &erst->erst_dma_addr, flags); if (!erst->entries) return -ENOMEM; @@ -394,7 +394,7 @@ static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, static void dbc_erst_free(struct device *dev, struct xhci_erst *erst) { - dma_free_coherent(dev, sizeof(struct xhci_erst_entry), erst->entries, + dma_free_coherent(dev, sizeof(*erst->entries), erst->entries, erst->erst_dma_addr); erst->entries = NULL; } @@ -494,7 +494,7 @@ static int xhci_dbc_mem_init(struct xhci_dbc *dbc, gfp_t flags) goto ctx_fail; /* Allocate the string table: */ - dbc->string_size = sizeof(struct dbc_str_descs); + dbc->string_size = sizeof(*dbc->string); dbc->string = dma_alloc_coherent(dev, dbc->string_size, &dbc->string_dma, flags); if (!dbc->string) From patchwork Mon Oct 2 16:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13406458 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FFEB1DA4B for ; Mon, 2 Oct 2023 16:18:54 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1EEEBD; Mon, 2 Oct 2023 09:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696263532; x=1727799532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=25mC9ayhiVvOyhyLLT89N3/FQzoVtawylvAn3pXdF80=; b=B2tePY5g5C67WekeQ/1V1wRaQ47IXSbbc9IY3mnpJhNrS+nFjq+TQ4s4 JDZ4F0HxZl0bo7pUN7vaVgPTK0YSMqOvmMLt3Hwbxnu8TYqo4KwG8DhcE CliNe6IKjsRMGSqqU5Rese7HF/kRIMCzO3KeG0eATUekY6FIX3Zcdp73k 7TzWAjPlDYhKb99oL8rcbPwvGF5h7+PTEK/mKtvo3E0MDNSoYfusXREjb z4d2Rx1iK39mvgA58acXnJ9vuU2FBhdk0KwwZgkiy+LxW71NCtdqBphU9 4CKPM1rWhYZ7IzZhnCkRXzQ9aoKKf0J2jS72LeEvuFmLFvncOl2CzN+yj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="362949543" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="362949543" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 09:16:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="816339811" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="816339811" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Oct 2023 09:16:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 898081665; Mon, 2 Oct 2023 19:16:20 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH v1 10/10] xhci: dbc: Add missing headers Date: Mon, 2 Oct 2023 19:16:10 +0300 Message-Id: <20231002161610.2648818-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> References: <20231002161610.2648818-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Don't inherit headers "by chances" from asm/bug.h, asm/io.h, etc... Include the needed headers explicitly. Signed-off-by: Andy Shevchenko --- drivers/usb/host/xhci-dbgcap.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 366ce3146a93..eb2e89bf31be 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -6,9 +6,24 @@ * * Author: Lu Baolu */ +#include #include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include #include "xhci.h" #include "xhci-trace.h"