From patchwork Mon Oct 16 13:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 735498 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 AC1422772A for ; Mon, 16 Oct 2023 13:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="a2FAnSit" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A00A2AB; Mon, 16 Oct 2023 06:09: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=1697461789; x=1728997789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wKIv3sJ1clYjdqjwiVvVRD9CCUCGlQHTF5I50Li2+CE=; b=a2FAnSity9U8+c9YPI7bdJ8uLCLCXe9/UnhpW0UjY9plAN/HrJlhGPdR AWgiEEIm/CItmeySEuzovep/ij2jObaf2+BO2iYmA0R41GPvrsisvBMpY RUP6RrkyysYaHS20UVqyAxWqHr3c6X38KrrVQv2KP1IiEAvkFc2SfJ9vM cDNKXNjOyQhFb3KrIhg99SCW9Nk+KDuDy+c1guJ9BhsJMVd5wuFSXo0LM sNrk2C9svR3nwl7Je/fn/VQM2jqVYMwhSA8x4YUtbj3EHSOXfEccFoj68 e8V0p5LCf3GZs1j5narvFUEypIkHR7wW67X6WbjrfkTvM8njGZVwZ6OdT w==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133288" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133288" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067131" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067131" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0707F11D; Mon, 16 Oct 2023 16:09:41 +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 v2 01/10] xhci: dbc: Drop duplicate checks for dma_free_coherent() Date: Mon, 16 Oct 2023 16:09:25 +0300 Message-Id: <20231016130934.1158504-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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,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 16 13:09:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 735499 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 4E28120B22 for ; Mon, 16 Oct 2023 13:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dfok7jaf" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E836BF5; Mon, 16 Oct 2023 06:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461787; x=1728997787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5wFq2LWIAxkbz3owrFJUzWLLHVZI7rE5EIksKjGKEtQ=; b=dfok7jafci87ko77G726DMhHigZPsbaTky0XT2Ty5RmmAqX4eGd/tCYq PDFXk8uRZ4JndD5CZa1XwuYAiTmJEk/L8wX+GfMT0Co7C5MYWoHJ5pSEM 1l/2MsvRg1P/uMW3M9DkG0NEO+uM3D+xqxxLFO+AIJuQ+ph49IJmfuVaq vm/kS8GnKCWpS+ejtKjQGQ/9M4Xc7haJ8UPTGOeQ8Lc34IFl+2YZdaKwV p56L/Ogj/OwYMhYYX1qG8kdmhQNq0I/NX2uTMiQZYkI60C6CT8dxmVER/ 97o/7WdwuIbL1FFK3DHum3kWIPDOR3nCmjkv1J1acZbX9ggvL5TQ4FQWp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="416590139" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="416590139" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="759385503" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="759385503" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 16 Oct 2023 06:09:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 10A7285E; Mon, 16 Oct 2023 16:09:42 +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 v2 02/10] xhci: dbc: Convert to use sysfs_streq() Date: Mon, 16 Oct 2023 16:09:26 +0300 Message-Id: <20231016130934.1158504-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 16 13:09:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 735494 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 8A95F27EC5 for ; Mon, 16 Oct 2023 13:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jv86L3BT" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 144CA107; Mon, 16 Oct 2023 06:09: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=1697461791; x=1728997791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IgxldMpH8a+wqMFSf6j151qigeL3anjzob39MFArgC4=; b=jv86L3BTnRvMD2N6nBGInbbsfrt6di4lwmFZqht8utFyVkY2w/dKB/6z 8IQDG0eAxpzIc95lP8tgAeEEzFqRmBI8srTmVImeioqUvwpANi5qTqCv0 xgSyfCQHsTwky2GJBvzhLRMNk8WAyeoIcW8gdVZh5/tas/CdWb+j1AfyN 74UhKxxdcsqplI/n/T/RBVBBP/CKHudNqym2U3yrvSJ62HO9Cu8nhw8OA 0viHAGNMR2Zb4MvCetWGGD+HZq8sLo+wLKBvacZFcVBSz1ykLX9OFag5W iqYbgqj2+I2rquCcFSgVEvB/8exT2vFxk/F0yrriGVLhO2a7z07R0/TDj Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133295" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133295" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067134" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067134" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1C14495B; Mon, 16 Oct 2023 16:09:42 +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 v2 03/10] xhci: dbc: Use sysfs_emit() to instead of scnprintf() Date: Mon, 16 Oct 2023 16:09:27 +0300 Message-Id: <20231016130934.1158504-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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,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 | 44 +++++++++++++--------------------- drivers/usb/host/xhci-dbgcap.h | 1 + 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index f505b79afe53..df14e336370d 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -910,41 +910,29 @@ 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) { - const char *p; struct xhci_dbc *dbc; struct xhci_hcd *xhci; 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 +965,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 +1005,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 +1044,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 +1084,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 16 13:09:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 734239 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 1FB1327719 for ; Mon, 16 Oct 2023 13:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Sladi6xo" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2764510E; Mon, 16 Oct 2023 06:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461788; x=1728997788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VH0RJCsrmhvVcZdnAPlndDrhI1n8zmF4zmgMquI63Ds=; b=Sladi6xohBQCxQxU/HD/YCUlSc0Wwm6nTwYn2GyTw+SRLps4Ek6CE7mB q/hVrP3JN2IzMXIPHjjCuDFwvkxX+5wXYrG1DvqBdKXHOqzN1SXVv5avk XL0aLHosNEPdHMINKuwWmZG74AGPZs0bZ6pa6PgfqrDg/pzUL401hEr8y z4C20tW1McB4ilLIIdYlPe88FD7/VWmYd9TulGuodzLuls95aNqGfxVLC sjF3Qb7KSGy4nO7/rKplhYmxMcSMQ59MrkAX8EiSWs9Iocmupke9ggFhc Tte12cQxIL07+//uvE0Kz8QtmOqlu+Avorhtm0hseGGn+MiRcz9bFeCSq A==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133286" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133286" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067129" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067129" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 29235988; Mon, 16 Oct 2023 16:09:42 +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 v2 04/10] xhci: dbc: Use ATTRIBUTE_GROUPS() Date: Mon, 16 Oct 2023 16:09:28 +0300 Message-Id: <20231016130934.1158504-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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,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 df14e336370d..660e3ee31dc6 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -1123,7 +1123,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, @@ -1131,10 +1131,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) @@ -1160,7 +1157,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; @@ -1179,7 +1176,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 16 13:09:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 734237 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 8D40E27EC6 for ; Mon, 16 Oct 2023 13:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XOM8812j" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4931EB; Mon, 16 Oct 2023 06:09: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=1697461788; x=1728997788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hSDxuqmZzlGLTaad8H323ocWfeLLf3evwalEGIIxd/4=; b=XOM8812jA4R+p9xmnk0se/VFY7u06lCigl4tLDe980crf/LroXAHGAkk xaqZNghZ9L5TRtsVqA76O6zAHslYIdND4Zo5m5WWC/dCSusvUcClLtZad 22GvtseLLgvagfLQHW1VSUoXoHqOMAVKZftOXpxeCoPN6RzllsO0hyacB LIOhAk6QJASSaX+ng259I5vmQTj3/39nFWjVGqS+9dK5SIE//pE21sGMP N6i35D1lVTrK7Kv/rwxvev9uKaP7Sz21BpqUt8VlQNUWMFaT/YQEYp43l TgH2SydHlqM9Y3Es37RtBpdO4TV+/iGk4ZpAlnmavf6j7M38N4ZTAW+o9 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="416590164" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="416590164" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="759385520" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="759385520" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 16 Oct 2023 06:09:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 30EBE9CE; Mon, 16 Oct 2023 16:09:42 +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 v2 05/10] xhci: dbc: Check for errors first in xhci_dbc_stop() Date: Mon, 16 Oct 2023 16:09:29 +0300 Message-Id: <20231016130934.1158504-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 660e3ee31dc6..6b9f4b839270 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 16 13:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 735496 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 71B7A2772A for ; Mon, 16 Oct 2023 13:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AyDZbrFe" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B76D10E; Mon, 16 Oct 2023 06:09: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=1697461792; x=1728997792; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C2LXIp8aDjt+KK6t7A/TPFPz1sfKbc8zCp7ovuaeChc=; b=AyDZbrFeI4AILfaW/oI0CxrSL15v6TqHJfammDH5ah/akitmuh6JdDAZ 5/V6KEaXVZpE+UYi/GLy721r5ft+Ta2AjlsfCF2sWttbh/INi1g8rQbWV RURORGn0F0PP6zNx6Ph8lUbfJUtCMC3wlyW29Kvj31kJz4JJ9NrpG24+H fZsZRLysZYyeNgaFpMI+6jKstUk6D6G8c03iLQOC/Q0BtM3Oq+V0a+r/E WBLMp6jQW5T5O6YNUVfKtQ1wRCviI9MzeI/O6XsyaF/CD5/MV8JuxbV9m +LScTFS+a8obhAiTA3nQBNTxc03WpY/rziwvIMbvM1eG3s72wEgAGH4Dt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133308" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133308" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067149" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067149" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 38F76A46; Mon, 16 Oct 2023 16:09:42 +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 v2 06/10] xhci: dbc: Don't shadow error codes in store() functions Date: Mon, 16 Oct 2023 16:09:30 +0300 Message-Id: <20231016130934.1158504-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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,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 6b9f4b839270..c211c69e8041 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -977,9 +977,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; @@ -1017,9 +1019,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; @@ -1056,9 +1060,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; @@ -1098,9 +1104,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 16 13:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 734236 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 A98F327ED7 for ; Mon, 16 Oct 2023 13:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XIQViUqa" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D7B3115; Mon, 16 Oct 2023 06:09: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=1697461792; x=1728997792; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0s6SJFl6EojiT5uelJ/E8mqMVnAxTbxFEfT6I0A+Yko=; b=XIQViUqaUkxTSJtkmExSMurd8hYWpg470aQbp4W7QfjD9UaDYG1EFdM9 erhPOvRO0zxFjoXJXPJLpiWsQ9G6TJJCN+oaKVvpZLkleYC8KcDTFM15p r5C9Q1yDF4kWMJSrqRJtXYv2vkmK+PVMFTlwx9QxehRL9OEtMCa+wA4ku IRJFFBNQYAzgvzhSFbhWF7tB2KJfbbKteUp0hWCOGDAoOGEz2D4Sgl4Wq 9WjcfX2/hPnDzjjDxyzek02vQTUag9xt/lqFkLwzUtln2bfMcJJ7fomR+ udcwlwl1MBVx0Q02N4E7cwetWHDxf+nABwCzNmggt22IljJdgIAOM/RSn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="416590161" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="416590161" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="759385518" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="759385518" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 16 Oct 2023 06:09:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 401CDA4A; Mon, 16 Oct 2023 16:09:42 +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 v2 07/10] xhci: dbc: Replace custom return value with proper Linux error code Date: Mon, 16 Oct 2023 16:09:31 +0300 Message-Id: <20231016130934.1158504-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 c211c69e8041..779a564ad698 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 16 13:09:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 734235 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 DF10E27ECD for ; Mon, 16 Oct 2023 13:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dC5wpAJm" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81F56F5; Mon, 16 Oct 2023 06:09: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=1697461791; x=1728997791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m/NysSCadA0TJULbiXS8GGWTrMOochBOaLvqBFQytEY=; b=dC5wpAJm7y7MTeUb3vuR/ZipZ93XxyoXmL3P9mVZK7jXi/a4pYq+If3J KsAnOWNpgkn48dwxO81XCQdBrmvbI5yun99QVyOvPGQm7+ZfIzsUcBVeL 3aolT2THksFfzKdXudti1N0MRnYNm+mK3rh6G3MmPtZ17ySei9kU+EgJs GZ170kqBGY8TfG9sLy7wZSVhWZ8/oYoQhQrq4t32Yzz8Eiuwj85mBKwx9 hPw+9Vqq7DS58N7zFpOeZ+oQ7aniRUzc9Hxg26+mw0GTlsuWg83zm3DFw 1pNuqg+0+XJActXXs2cdSTyR767pW1NHDnNa8IkzUWuXFiBQlueng5Gxc g==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133305" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133305" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067145" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067145" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4DCC2A59; Mon, 16 Oct 2023 16:09:42 +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 v2 08/10] xhci: dbc: Use sizeof_field() where it makes sense Date: Mon, 16 Oct 2023 16:09:32 +0300 Message-Id: <20231016130934.1158504-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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,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 779a564ad698..0c9fd61e9c5b 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 16 13:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 735495 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 DFB1C27EDA for ; Mon, 16 Oct 2023 13:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OEg2dXdp" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52DF710B; Mon, 16 Oct 2023 06:09: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=1697461793; x=1728997793; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lQnIe93FuRHO1a3TqxHeJWs2dtVteDAULQEqBRGV2bo=; b=OEg2dXdpTxdBtTvfw1urqi8SIDVuMI0YdqKf+G/wZ5SwsZM2DQGoI5c2 yJX5eZrzdSrFNHbD4bPPrMMiglt/aFC9yZ4v7ucE1VKT0dEQXh77fT1po RDFZ5Wg/rUMC2Ot9zu+JIfeOlQkT9JCKckmqs8haK+Qy/pesyoeyLOGEf dIy7Huc8n8d6JetvU3iddy0AoA9XcAybtdou6VRPKoVDRJ+AlZ+/6eQ/i XXV59oLRtrhZgSAKGPKhc49xmZmr21w4l/Py44DKio68fcXk46+QRbuUP 8Se6HmVe7s0FF6BB9Fb4BBpsjW1ZTjhWz+9rSXi6BPpQBB4DnnfeqsoTi Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4133309" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4133309" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087067148" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087067148" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2023 06:09:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 533B081C; Mon, 16 Oct 2023 16:09:42 +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 v2 09/10] xhci: dbc: Use sizeof(*pointer) instead of sizeof(type) Date: Mon, 16 Oct 2023 16:09:33 +0300 Message-Id: <20231016130934.1158504-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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,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 0c9fd61e9c5b..73494d55b0be 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 16 13:09:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 735497 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 6B28227EC2 for ; Mon, 16 Oct 2023 13:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZVx5nvbD" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27247F7; Mon, 16 Oct 2023 06:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461789; x=1728997789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ycKEu6aIli6lxZMS9klc458Zt4d5Yco6j3mjsSXjEcE=; b=ZVx5nvbD8G2ZM6GvG/c6x5y0hrQHWEMNohBnpmt2pr3LIHzyffSdZrjy FfQysvRwbfqk3x2FjkWxFmACmkclz7PjW7g7iEglgdvflMSpGSestubkR ZT/wnekmrhuVL/7YMJcSZqsf1d2SKtLB+tq87/RIP1l9FHicchk1JcUH3 7uWVLhkUhuE2OM3B6jlcVrhOMIOMIW2KvhrmRp3xYHWA4RW/ohtGgsQsF QFL5Glw+mRlXpkqWp/pxv2e8b29f3wJQ67ZzYoImOPUjVk2Ox9FvXpefe 4ga1TB74viVA2+buTcSnVPtjQ5l4da5jF2rwLXwvuoJTzoL6ROPtwmku3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="416590166" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="416590166" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 06:09:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="759385522" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="759385522" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 16 Oct 2023 06:09:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 626A9BC2; Mon, 16 Oct 2023 16:09:42 +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 v2 10/10] xhci: dbc: Add missing headers Date: Mon, 16 Oct 2023 16:09:34 +0300 Message-Id: <20231016130934.1158504-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016130934.1158504-1-andriy.shevchenko@linux.intel.com> References: <20231016130934.1158504-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 73494d55b0be..d82935d31126 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"