From patchwork Mon Aug 17 18:46:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A59C618 for ; Mon, 17 Aug 2020 18:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62BA52076E for ; Mon, 17 Aug 2020 18:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391631AbgHQSrV (ORCPT ); Mon, 17 Aug 2020 14:47:21 -0400 Received: from mga11.intel.com ([192.55.52.93]:46461 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391619AbgHQSrH (ORCPT ); Mon, 17 Aug 2020 14:47:07 -0400 IronPort-SDR: egL61fmZD8KnEKevHHf8O1Zy+HnC7Cg1O26VxUNCjN0ikhyYJrPrP0r1EK0/X73ZS/+r9NrP3J Qab6RBCzZ2sQ== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152409957" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="152409957" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:04 -0700 IronPort-SDR: BR9WGLrTtE04rvvqaDd5SGftfv2f3/R5k0PBljCTQrf0WxApARI04vJGt1qB3JMIiNwY5Q4RSn pTtqA7dmDu7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="496574798" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 17 Aug 2020 11:47:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5233616D; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko , Anton Sviridenko , Andrey Utkin , Ismael Luceno , Mauro Carvalho Chehab , Jussi Kivilinna , Kalle Valo , Jeff Kirsher , Sylwia Wnuczko , Jesse Brandeburg Subject: [PATCH v2 1/8] byteorder: Introduce cpu_to_le16_array() and le16_to_cpu_array() Date: Mon, 17 Aug 2020 21:46:52 +0300 Message-Id: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Introduce cpu_to_le16_array() and le16_to_cpu_array() for existing and future users. Signed-off-by: Andy Shevchenko Cc: Anton Sviridenko Cc: Andrey Utkin Cc: Ismael Luceno Cc: Mauro Carvalho Chehab Cc: Jussi Kivilinna Cc: Kalle Valo Cc: Jeff Kirsher Cc: Sylwia Wnuczko Cc: Jesse Brandeburg --- v2: split out of the USB patch The idea, how I see it, is to push entire series via USB tree as a main target of it. The immutable branch can be used for others to pick up. Of course maintainers can propose better approach. include/linux/byteorder/generic.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h index 4b13e0a3e15b..24904ad79df0 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -156,6 +156,22 @@ static inline void le64_add_cpu(__le64 *var, u64 val) *var = cpu_to_le64(le64_to_cpu(*var) + val); } +static inline void cpu_to_le16_array(__le16 *dst, const u16 *src, size_t len) +{ + int i; + + for (i = 0; i < len; i++) + dst[i] = cpu_to_le16(src[i]); +} + +static inline void le16_to_cpu_array(u16 *dst, const __le16 *src, size_t len) +{ + int i; + + for (i = 0; i < len; i++) + dst[i] = le16_to_cpu(src[i]); +} + /* XXX: this stuff can be optimized */ static inline void le32_to_cpu_array(u32 *buf, unsigned int words) { From patchwork Mon Aug 17 18:46:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D0A016B1 for ; Mon, 17 Aug 2020 18:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3509A2076E for ; Mon, 17 Aug 2020 18:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391632AbgHQSrW (ORCPT ); Mon, 17 Aug 2020 14:47:22 -0400 Received: from mga02.intel.com ([134.134.136.20]:34836 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391618AbgHQSrG (ORCPT ); Mon, 17 Aug 2020 14:47:06 -0400 IronPort-SDR: YL9R4L/LIPW1pQGB+IJ5zLwlGPDU+StvLSYClm+XghAkMZvCVaYCi4xRrOwmZJntgV2gLp/i/8 +xa6bNOO1cLA== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="142602246" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="142602246" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:03 -0700 IronPort-SDR: D/RGaahK3xJecEL8vann8F2/bK2yyMCSusXS+36fmSbhlnro7ReRxBzEnWaAYKixfsyFipjAf5 K/EY5VyERF4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="400283129" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 17 Aug 2020 11:47:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 619B111E; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko , Anton Sviridenko , Andrey Utkin , Ismael Luceno , Mauro Carvalho Chehab Subject: [PATCH v2 2/8] media: solo6x10: Make use of cpu_to_le16_array() Date: Mon, 17 Aug 2020 21:46:53 +0300 Message-Id: <20200817184659.58419-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since we have a new helper, let's replace open coded variant by it. Signed-off-by: Andy Shevchenko Cc: Anton Sviridenko Cc: Andrey Utkin Cc: Ismael Luceno Cc: Mauro Carvalho Chehab Signed-off-by: Ismael Luceno --- v2: new patch drivers/media/pci/solo6x10/solo6x10-disp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/solo6x10/solo6x10-disp.c b/drivers/media/pci/solo6x10/solo6x10-disp.c index ad98ca7fb98b..09c0cf8a5fcb 100644 --- a/drivers/media/pci/solo6x10/solo6x10-disp.c +++ b/drivers/media/pci/solo6x10/solo6x10-disp.c @@ -202,16 +202,15 @@ int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch, { const unsigned size = sizeof(u16) * 64; u32 off = SOLO_MOT_FLAG_AREA + ch * SOLO_MOT_THRESH_SIZE * 2; + unsigned int y; __le16 *buf; - int x, y; int ret = 0; buf = kzalloc(size, GFP_KERNEL); if (buf == NULL) return -ENOMEM; for (y = 0; y < SOLO_MOTION_SZ; y++) { - for (x = 0; x < SOLO_MOTION_SZ; x++) - buf[x] = cpu_to_le16(thresholds[y * SOLO_MOTION_SZ + x]); + cpu_to_le16_array(buf, &thresholds[y * SOLO_MOTION_SZ], SOLO_MOTION_SZ); ret |= solo_p2m_dma(solo_dev, 1, buf, SOLO_MOTION_EXT_ADDR(solo_dev) + off + y * size, size, 0, 0); From patchwork Mon Aug 17 18:46:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 862EF13A4 for ; Mon, 17 Aug 2020 18:47:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C72F204EC for ; Mon, 17 Aug 2020 18:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391630AbgHQSrP (ORCPT ); Mon, 17 Aug 2020 14:47:15 -0400 Received: from mga11.intel.com ([192.55.52.93]:46455 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391616AbgHQSrG (ORCPT ); Mon, 17 Aug 2020 14:47:06 -0400 IronPort-SDR: 3oiV5GhJYWGHKHHhwYA+Jd67hQpKArtIyeIxfRvWHdube25g9iiuP/1GZEhSp3fT72xtKsURJl D+uOixhVF6IQ== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152409953" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="152409953" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:02 -0700 IronPort-SDR: 79fxeyZtIp2RDRU5KxJboLT6uCp5CZUFMBtvkDX90LZ75AEcyT17MNvJfCIqnXhCn5WQ1yt9Iq v8bkgNOS/w3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="496574793" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 17 Aug 2020 11:47:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 66C7D1A3; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko , Jussi Kivilinna , Kalle Valo Subject: [PATCH v2 3/8] rndis_wlan: Make use of cpu_to_le16_array() Date: Mon, 17 Aug 2020 21:46:54 +0300 Message-Id: <20200817184659.58419-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since we have a new helper, let's replace open coded variant by it. Signed-off-by: Andy Shevchenko Cc: Jussi Kivilinna Cc: Kalle Valo Reported-by: kernel test robot Acked-by: Kalle Valo --- v2: new patch drivers/net/wireless/rndis_wlan.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 8852a1832951..06850ee6d6dc 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -859,9 +859,12 @@ static int rndis_set_config_parameter(struct usbnet *dev, char *param, int value_type, void *value) { struct ndis_config_param *infobuf; - int value_len, info_len, param_len, ret, i; + int value_len, info_len, param_len, ret; __le16 *unibuf; __le32 *dst_value; +#ifdef DEBUG + int i; +#endif if (value_type == 0) value_len = sizeof(__le32); @@ -901,13 +904,11 @@ static int rndis_set_config_parameter(struct usbnet *dev, char *param, /* simple string to unicode string conversion */ unibuf = (void *)infobuf + sizeof(*infobuf); - for (i = 0; i < param_len / sizeof(__le16); i++) - unibuf[i] = cpu_to_le16(param[i]); + cpu_to_le16_array(unibuf, param, param_len / sizeof(__le16)); if (value_type == 2) { unibuf = (void *)infobuf + sizeof(*infobuf) + param_len; - for (i = 0; i < value_len / sizeof(__le16); i++) - unibuf[i] = cpu_to_le16(((u8 *)value)[i]); + cpu_to_le16_array(unibuf, value, value_len / sizeof(__le16)); } else { dst_value = (void *)infobuf + sizeof(*infobuf) + param_len; *dst_value = cpu_to_le32(*(u32 *)value); From patchwork Mon Aug 17 18:46:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719115 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8207618 for ; Mon, 17 Aug 2020 18:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96DD920578 for ; Mon, 17 Aug 2020 18:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391614AbgHQSrL (ORCPT ); Mon, 17 Aug 2020 14:47:11 -0400 Received: from mga17.intel.com ([192.55.52.151]:6211 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391615AbgHQSrF (ORCPT ); Mon, 17 Aug 2020 14:47:05 -0400 IronPort-SDR: S0CYcS3uaZ6aSXTEez6C1XDP02BFjqij+zbINeS1ohN9U30jZLWhVDr/u0RVAjiWf77CEDeo6n q7/QLNlWZKng== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="134834836" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="134834836" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:02 -0700 IronPort-SDR: Oue4+mnNytP8+qxUku0BpW47W75srMVS2ZoPRHaRaaDMgLS8u0BI3jVyRNZCmVhob2QAmMgHiE /wObX+J0/s4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="279195010" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 17 Aug 2020 11:47:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6BD8F1C5; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko , Jeff Kirsher , Sylwia Wnuczko Subject: [PATCH v2 4/8] i40e: Make use of le16_to_cpu_array() Date: Mon, 17 Aug 2020 21:46:55 +0300 Message-Id: <20200817184659.58419-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since we have a new helper, let's replace open coded variant by it. Signed-off-by: Andy Shevchenko Cc: Jeff Kirsher Cc: Sylwia Wnuczko --- v2: new patch drivers/net/ethernet/intel/i40e/i40e_nvm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c index 7164f4ad8120..154505f352bc 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c +++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c @@ -444,7 +444,6 @@ static i40e_status i40e_read_nvm_buffer_aq(struct i40e_hw *hw, u16 offset, u16 read_size; bool last_cmd = false; u16 words_read = 0; - u16 i = 0; do { /* Calculate number of bytes we should read in this step. @@ -475,8 +474,7 @@ static i40e_status i40e_read_nvm_buffer_aq(struct i40e_hw *hw, u16 offset, offset += read_size; } while (words_read < *words); - for (i = 0; i < *words; i++) - data[i] = le16_to_cpu(((__le16 *)data)[i]); + le16_to_cpu_array(data, data, *words); read_nvm_buffer_aq_exit: *words = words_read; From patchwork Mon Aug 17 18:46:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D94A618 for ; Mon, 17 Aug 2020 18:47:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F1BE2072E for ; Mon, 17 Aug 2020 18:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391628AbgHQSrU (ORCPT ); Mon, 17 Aug 2020 14:47:20 -0400 Received: from mga12.intel.com ([192.55.52.136]:13890 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391617AbgHQSrH (ORCPT ); Mon, 17 Aug 2020 14:47:07 -0400 IronPort-SDR: 1Wyq+2FLJnBK2sb9veiYx8tk30Bt2BsI+ZMGBB5I7F14ghqtdEttT2mpxYg0n5jOISNZVG/Wsn tFItISb6kmag== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="134293874" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="134293874" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:03 -0700 IronPort-SDR: mHZjw8jse/XqMjn0OgkmVZFEniFjZucScjZsFB/Cm4h/VEMsMhM49PDNAZYXOwVXeM8GRfAWrm uuk2A5AKXBFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="334157251" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 17 Aug 2020 11:47:01 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 76FDB3D7; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko , Jeff Kirsher , Jesse Brandeburg Subject: [PATCH v2 5/8] ice: Make use of le16_to_cpu_array() Date: Mon, 17 Aug 2020 21:46:56 +0300 Message-Id: <20200817184659.58419-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since we have a new helper, let's replace open coded variant by it. Signed-off-by: Andy Shevchenko Cc: Jeff Kirsher Cc: Jesse Brandeburg --- v2: new patch drivers/net/ethernet/intel/ice/ice_nvm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c index 5903a36763de..3c376cb49e61 100644 --- a/drivers/net/ethernet/intel/ice/ice_nvm.c +++ b/drivers/net/ethernet/intel/ice/ice_nvm.c @@ -448,8 +448,8 @@ static enum ice_status ice_get_netlist_ver_info(struct ice_hw *hw) enum ice_status ret; u32 id_blk_start; __le16 raw_data; - u16 data, i; u16 *buff; + u16 data; ret = ice_acquire_nvm(hw, ICE_RES_READ); if (ret) @@ -494,8 +494,7 @@ static enum ice_status ice_get_netlist_ver_info(struct ice_hw *hw) if (ret) goto exit_error; - for (i = 0; i < ICE_AQC_NVM_NETLIST_ID_BLK_LEN; i++) - buff[i] = le16_to_cpu(((__force __le16 *)buff)[i]); + le16_to_cpu_array(buff, buff, ICE_AQC_NVM_NETLIST_ID_BLK_LEN); ver->major = (buff[ICE_AQC_NVM_NETLIST_ID_BLK_MAJOR_VER_HIGH] << 16) | buff[ICE_AQC_NVM_NETLIST_ID_BLK_MAJOR_VER_LOW]; From patchwork Mon Aug 17 18:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F53513A4 for ; Mon, 17 Aug 2020 18:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2178920578 for ; Mon, 17 Aug 2020 18:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391629AbgHQSrV (ORCPT ); Mon, 17 Aug 2020 14:47:21 -0400 Received: from mga02.intel.com ([134.134.136.20]:34839 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391620AbgHQSrH (ORCPT ); Mon, 17 Aug 2020 14:47:07 -0400 IronPort-SDR: uskqGMA10Oma3oy37AdN2b1njuurMuC0zDWbROcwamNVa70IzZUhEmyKRWkpO1ldQdqWaSgQV7 FRCFpJV7BX2A== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="142602249" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="142602249" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:05 -0700 IronPort-SDR: NhoMsZxUMqWQ9n8/ODTRfpZKUWhcMWJqqbvgkg6avL8P6CxfK21tebRG9a4wOT+1wTxXXjkhpJ 53rzTcsashmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="326493007" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 17 Aug 2020 11:47:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7E0C2411; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko Subject: [PATCH v2 6/8] usb: early: xhci-dbc: use readl_poll_timeout() to simplify code Date: Mon, 17 Aug 2020 21:46:57 +0300 Message-Id: <20200817184659.58419-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout() to poll the status of the registers. Signed-off-by: Andy Shevchenko --- v2: no change drivers/usb/early/xhci-dbc.c | 56 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index c0507767a8e3..77c2e8301971 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -131,38 +132,23 @@ static u32 __init xdbc_find_dbgp(int xdbc_num, u32 *b, u32 *d, u32 *f) return -1; } -static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait, int delay) -{ - u32 result; - - do { - result = readl(ptr); - result &= mask; - if (result == done) - return 0; - udelay(delay); - wait -= delay; - } while (wait > 0); - - return -ETIMEDOUT; -} - static void __init xdbc_bios_handoff(void) { int offset, timeout; u32 val; offset = xhci_find_next_ext_cap(xdbc.xhci_base, 0, XHCI_EXT_CAPS_LEGACY); - val = readl(xdbc.xhci_base + offset); - if (val & XHCI_HC_BIOS_OWNED) { + val = readl(xdbc.xhci_base + offset); + if (val & XHCI_HC_BIOS_OWNED) writel(val | XHCI_HC_OS_OWNED, xdbc.xhci_base + offset); - timeout = handshake(xdbc.xhci_base + offset, XHCI_HC_BIOS_OWNED, 0, 5000, 10); - if (timeout) { - pr_notice("failed to hand over xHCI control from BIOS\n"); - writel(val & ~XHCI_HC_BIOS_OWNED, xdbc.xhci_base + offset); - } + timeout = readl_poll_timeout_atomic(xdbc.xhci_base + offset, val, + !(val & XHCI_HC_BIOS_OWNED), + 10, 5000); + if (timeout) { + pr_notice("failed to hand over xHCI control from BIOS\n"); + writel(val & ~XHCI_HC_BIOS_OWNED, xdbc.xhci_base + offset); } /* Disable BIOS SMIs and clear all SMI events: */ @@ -421,7 +407,9 @@ static int xdbc_start(void) ctrl = readl(&xdbc.xdbc_reg->control); writel(ctrl | CTRL_DBC_ENABLE | CTRL_PORT_ENABLE, &xdbc.xdbc_reg->control); - ret = handshake(&xdbc.xdbc_reg->control, CTRL_DBC_ENABLE, CTRL_DBC_ENABLE, 100000, 100); + ret = readl_poll_timeout_atomic(&xdbc.xdbc_reg->control, ctrl, + (ctrl & CTRL_DBC_ENABLE) == CTRL_DBC_ENABLE, + 100, 100000); if (ret) { xdbc_trace("failed to initialize hardware\n"); return ret; @@ -432,14 +420,18 @@ static int xdbc_start(void) xdbc_reset_debug_port(); /* Wait for port connection: */ - ret = handshake(&xdbc.xdbc_reg->portsc, PORTSC_CONN_STATUS, PORTSC_CONN_STATUS, 5000000, 100); + ret = readl_poll_timeout_atomic(&xdbc.xdbc_reg->portsc, status, + (status & PORTSC_CONN_STATUS) == PORTSC_CONN_STATUS, + 100, 5000000); if (ret) { xdbc_trace("waiting for connection timed out\n"); return ret; } /* Wait for debug device to be configured: */ - ret = handshake(&xdbc.xdbc_reg->control, CTRL_DBC_RUN, CTRL_DBC_RUN, 5000000, 100); + ret = readl_poll_timeout_atomic(&xdbc.xdbc_reg->control, status, + (status & CTRL_DBC_RUN) == CTRL_DBC_RUN, + 100, 5000000); if (ret) { xdbc_trace("waiting for device configuration timed out\n"); return ret; @@ -523,11 +515,14 @@ static int xdbc_bulk_transfer(void *data, int size, bool read) static int xdbc_handle_external_reset(void) { - int ret = 0; + u32 result; + int ret; xdbc.flags = 0; writel(0, &xdbc.xdbc_reg->control); - ret = handshake(&xdbc.xdbc_reg->control, CTRL_DBC_ENABLE, 0, 100000, 10); + ret = readl_poll_timeout_atomic(&xdbc.xdbc_reg->control, result, + !(result & CTRL_DBC_ENABLE), + 10, 100000); if (ret) goto reset_out; @@ -552,10 +547,13 @@ static int xdbc_handle_external_reset(void) static int __init xdbc_early_setup(void) { + u32 result; int ret; writel(0, &xdbc.xdbc_reg->control); - ret = handshake(&xdbc.xdbc_reg->control, CTRL_DBC_ENABLE, 0, 100000, 100); + ret = readl_poll_timeout_atomic(&xdbc.xdbc_reg->control, result, + !(result & CTRL_DBC_ENABLE), + 100, 100000); if (ret) return ret; From patchwork Mon Aug 17 18:46:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E61D618 for ; Mon, 17 Aug 2020 18:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 900C520772 for ; Mon, 17 Aug 2020 18:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390085AbgHQSrU (ORCPT ); Mon, 17 Aug 2020 14:47:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:34836 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391628AbgHQSrO (ORCPT ); Mon, 17 Aug 2020 14:47:14 -0400 IronPort-SDR: 9KvaRhHUdq/OXIamnPQt2HVOQgdrwBSDN3r6sWqG22+bFb7HwniyPEEGYU4zlcrOEDZnWNPQGt Cao+JEfaUKlA== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="142602250" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="142602250" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:05 -0700 IronPort-SDR: JjAghirCwbBFETuxjL/t9gyN/ap9xBtlOutOnZmrsCLiiniZg4u5QJCJjN3Wjlzav0iWUwrWi4 7AFBV8U4whLw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="326493009" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 17 Aug 2020 11:47:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 855A9456; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko Subject: [PATCH v2 7/8] usb: early: xhci-dbc: Make use of cpu_to_le16_array() Date: Mon, 17 Aug 2020 21:46:58 +0300 Message-Id: <20200817184659.58419-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since we have a new helper, let's replace open coded variant by it. Signed-off-by: Andy Shevchenko Reported-by: kernel test robot --- v2: updated commit message due to split (see patch 1) drivers/usb/early/xhci-dbc.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index 77c2e8301971..c5761ea9394d 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ +#include #include #include #include @@ -200,14 +201,6 @@ static void xdbc_reset_ring(struct xdbc_ring *ring) } } -static inline void xdbc_put_utf16(u16 *s, const char *c, size_t size) -{ - int i; - - for (i = 0; i < size; i++) - s[i] = cpu_to_le16(c[i]); -} - static void xdbc_mem_init(void) { struct xdbc_ep_context *ep_in, *ep_out; @@ -263,7 +256,7 @@ static void xdbc_mem_init(void) s_desc->bLength = (strlen(XDBC_STRING_SERIAL) + 1) * 2; s_desc->bDescriptorType = USB_DT_STRING; - xdbc_put_utf16(s_desc->wData, XDBC_STRING_SERIAL, strlen(XDBC_STRING_SERIAL)); + cpu_to_le16_array(s_desc->wData, XDBC_STRING_SERIAL, strlen(XDBC_STRING_SERIAL)); string_length = s_desc->bLength; string_length <<= 8; @@ -272,7 +265,7 @@ static void xdbc_mem_init(void) s_desc->bLength = (strlen(XDBC_STRING_PRODUCT) + 1) * 2; s_desc->bDescriptorType = USB_DT_STRING; - xdbc_put_utf16(s_desc->wData, XDBC_STRING_PRODUCT, strlen(XDBC_STRING_PRODUCT)); + cpu_to_le16_array(s_desc->wData, XDBC_STRING_PRODUCT, strlen(XDBC_STRING_PRODUCT)); string_length += s_desc->bLength; string_length <<= 8; @@ -281,7 +274,7 @@ static void xdbc_mem_init(void) s_desc->bLength = (strlen(XDBC_STRING_MANUFACTURER) + 1) * 2; s_desc->bDescriptorType = USB_DT_STRING; - xdbc_put_utf16(s_desc->wData, XDBC_STRING_MANUFACTURER, strlen(XDBC_STRING_MANUFACTURER)); + cpu_to_le16_array(s_desc->wData, XDBC_STRING_MANUFACTURER, strlen(XDBC_STRING_MANUFACTURER)); string_length += s_desc->bLength; string_length <<= 8; From patchwork Mon Aug 17 18:46:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11719133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA547618 for ; Mon, 17 Aug 2020 18:47:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA4582075B for ; Mon, 17 Aug 2020 18:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391618AbgHQSrZ (ORCPT ); Mon, 17 Aug 2020 14:47:25 -0400 Received: from mga07.intel.com ([134.134.136.100]:35541 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391622AbgHQSrG (ORCPT ); Mon, 17 Aug 2020 14:47:06 -0400 IronPort-SDR: ab/K1TZoifOm6Thwb4jry2E/X7DogfSMyk3TW5cv5UwT9oTLcvsdlIEuYwzrMlcXj7p4vCqnan eY/3fW3JqnkA== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="219094510" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="219094510" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 11:47:05 -0700 IronPort-SDR: TS+6oa9tqjdbayqVyJ/nGUU6NM3rgiPg5+9RNzFsUn5eJw2VIAk5nqrKwUZT+AAXIim3QAWf/S b+ZKtrQ8RNeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="440961837" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 17 Aug 2020 11:47:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8C6E946E; Mon, 17 Aug 2020 21:47:00 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman Cc: Andy Shevchenko Subject: [PATCH v2 8/8] usb: early: xhci-dbc: Move asm/* headers after linux/* Date: Mon, 17 Aug 2020 21:46:59 +0300 Message-Id: <20200817184659.58419-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> References: <20200817184659.58419-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org asm/* are less generic and should be included after linux/* ones. Signed-off-by: Andy Shevchenko --- v2: moved only asm/* and preserved ordering of the rest (Greg) drivers/usb/early/xhci-dbc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index c5761ea9394d..104b932a9c93 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -16,8 +16,6 @@ #include #include #include -#include -#include #include #include #include @@ -25,6 +23,9 @@ #include #include +#include +#include + #include "../host/xhci.h" #include "xhci-dbc.h"