Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp347805pxf; Wed, 10 Mar 2021 07:35:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTxdHOAOhLtR+c55z8IMFMX56//3Y7ttttaRfGl9wWh596SGFxiOg/aT3oBCuuwpYaFjdg X-Received: by 2002:a17:906:5295:: with SMTP id c21mr4310616ejm.67.1615390539549; Wed, 10 Mar 2021 07:35:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615390539; cv=none; d=google.com; s=arc-20160816; b=bkatMohfILrp+a+oUpeFH0v57ve4tiVy/p/ZSAgnEpeP34zXk2UEAQtAU/ZwAKmL6G 97I6Iz+2/xMTUZ0BI8hyD5xo7VDx9rqE+sTRiMKy87Y/HKxT+EHTVetlfZrRfG2ugdAT oCADIG4PbKa3ankFKkvT4CPr2+z/Zh0b17bOk11h6Mjfyp88pk99rXH4IoQX/CxwyOYX ail/dy2FFZf847Zhu/pr0+TFpGghrtBzB9H2LGWj/S4bR0iPqXfxYvPY5RGqQeo/kE1k Lw7MlbKPz5+aHmPXHVIhh0V5gNyzMidhcfG9KHq0vi+h/Rg5td4my1eLUMjdJAqQof3V NqKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:reply-to:cc:from:to:dkim-signature:date; bh=xIbVmZTNCK7NxoQif0UR7b5khjYZuE9aBt1T+sqg4TA=; b=W14Z36ZXnDI8vEsJGFtXBRX4iCZVpHRMG+ROlDMz3urfNGLJVgA3HwEf705f9vCtXY kd2gpYjqbL4wthXBfa+ur7KeL9Q13QauX7gLrNJsahwHOXGuIjQNe+rDm6UbGe4topd+ qUvvDOi3mK4R0LVUD0Ao7db1DyCcOb+cac+wt5uT9TkEKFdA4JS1fiUFdBT7DJ8BMc7k Ezky5v/BI/AG4U+1QXVB6I0j/q3JXTli9XOj1Kma2mj8+VQalJTGDjXzx+gLrpbFV0Mo dGMlxy7t4TWZ44an3yxdBo+oflUx9rGfl9BNYzdpEIJw7J9t7l9XkEg9Gozc7ZX8bsLp u2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@connolly.tech header.s=protonmail header.b=Qi9eXAJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=connolly.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yr5si11787530ejb.728.2021.03.10.07.35.16; Wed, 10 Mar 2021 07:35:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@connolly.tech header.s=protonmail header.b=Qi9eXAJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=connolly.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233015AbhCJPdu (ORCPT + 99 others); Wed, 10 Mar 2021 10:33:50 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:47112 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232965AbhCJPdo (ORCPT ); Wed, 10 Mar 2021 10:33:44 -0500 Date: Wed, 10 Mar 2021 15:33:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connolly.tech; s=protonmail; t=1615390420; bh=xIbVmZTNCK7NxoQif0UR7b5khjYZuE9aBt1T+sqg4TA=; h=Date:To:From:Cc:Reply-To:Subject:From; b=Qi9eXAJJiC2p6vv8kRNMGX3hSUO1dbqGFRKhTn2K72HtfyBIFCtKEZ2aCavDCpKiN kN/bfVuB0K6elcBV57Zozz3QjKAMqigbcTTwBJfrlHaW0AIir78r9tlOIO1eyoOIjP a4oo7LItdMpZeza3ZE73PLu4KUTY5RnPH1ZbtDQs= To: caleb@connolly.tech From: Caleb Connolly Cc: alim.akhtar@samsung.com, avri.altman@wdc.com, ejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, cang@codeaurora.org, beanhuo@micron.com, jaegeuk@kernel.org, asutoshd@codeaurora.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Caleb Connolly Subject: v3: scsi: ufshcd: use a macro for UFS versions Message-ID: <20210310153215.371227-1-caleb@connolly.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using a device with UFS > 2.1 the error "invalid UFS version" is misleadingly printed. There was a patch for this almost a year ago to which this solution was suggested. This series replaces the use of the growing UFSHCI_VERSION_xy macros with an inline function to encode a major and minor version into the scheme used on devices, that being: (major << 8) + (minor << 4) I dealt with the different encoding used for UFS 1.x by converting it to match the newer versions in ufshcd_get_ufs_version(). That means it's possible to use comparisons for version checks, e.g. if (hba->ufs_version < ufshci_version(3, 0)) ... I've also dropped the "invalid UFS version" check entirely as it seems to be more misleading than useful, and hasn't been accurate for a long time. This has been tested on a device with UFS 3.0 and a device with UFS 2.1, however I don't own any older devices to test with. Caleb --- Changes since v1: * Switch from macro to static inline function * Address Christoph's formatting comments * Add Nitin's signoff on patch 3 ("scsi: ufshcd: remove version check") Resend: * Fix patches 1/3 referencing the macro from v1 instead of the new inline function Changes since v2: * Remove excessive parentheses from ufshci_version() * Pick up Christoph's Reviewed-by Caleb Connolly (3): scsi: ufshcd: use a function to calculate versions scsi: ufs: qcom: use ufshci_version function scsi: ufshcd: remove version check drivers/scsi/ufs/ufs-qcom.c | 4 +-- drivers/scsi/ufs/ufshcd.c | 66 ++++++++++++++++++-----------------------= ---- drivers/scsi/ufs/ufshci.h | 17 +++++++----- 3 files changed, 38 insertions(+), 49 deletions(-)