From ff6f3c69163424b6909e99a3d62dbf723c9834bd Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Thu, 12 Oct 2023 13:49:45 +0100 Subject: [PATCH] scsi: ufs: Clean-up headers Clean-up the UFS headers by adding a new top-level header for ufshcd.h, ufshci.h and unipro.h that will include the appropriate header depending on kernel version. This saves replicating the kernel version check for every source file that includes these headers. Note that the ufshcd-pltfrm.h header is identical between v5.15, v5.16 and 6.1 kernels and so remove the duplicated versions of this header and just use a common header for all kernel versions. Bug 4221847 Change-Id: I0e0ba2f4389af7e34ab62e3131141405d87aeeb1 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2996211 (cherry picked from commit 54e01347ea67eb9d5dd3dee7d9a4e5966ab77c6a) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3031885 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- drivers/scsi/ufs/ufs-provision-dummy.c | 8 +---- drivers/scsi/ufs/ufs-provision.c | 8 +---- drivers/scsi/ufs/ufs-provision.h | 8 +---- drivers/scsi/ufs/ufs-tegra-common.c | 20 +++-------- .../scsi/ufs/k516/ufshcd-pltfrm.h | 36 ------------------- .../scsi/ufs/k61/ufshcd-pltfrm.h | 36 ------------------- .../scsi/ufs/{k515 => }/ufshcd-pltfrm.h | 0 include/drivers-private/scsi/ufs/ufshcd.h | 12 +++++++ include/drivers-private/scsi/ufs/ufshci.h | 12 +++++++ include/drivers-private/scsi/ufs/unipro.h | 12 +++++++ 10 files changed, 43 insertions(+), 109 deletions(-) delete mode 100644 include/drivers-private/scsi/ufs/k516/ufshcd-pltfrm.h delete mode 100644 include/drivers-private/scsi/ufs/k61/ufshcd-pltfrm.h rename include/drivers-private/scsi/ufs/{k515 => }/ufshcd-pltfrm.h (100%) create mode 100644 include/drivers-private/scsi/ufs/ufshcd.h create mode 100644 include/drivers-private/scsi/ufs/ufshci.h create mode 100644 include/drivers-private/scsi/ufs/unipro.h diff --git a/drivers/scsi/ufs/ufs-provision-dummy.c b/drivers/scsi/ufs/ufs-provision-dummy.c index 64301fbb..9d1e5411 100644 --- a/drivers/scsi/ufs/ufs-provision-dummy.c +++ b/drivers/scsi/ufs/ufs-provision-dummy.c @@ -6,13 +6,7 @@ #include "ufs-tegra.h" #ifdef CONFIG_DEBUG_FS -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -#include -#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) -#include -#else -#include -#endif +#include void debugfs_provision_init(struct ufs_hba *hba, struct dentry *device_root) { diff --git a/drivers/scsi/ufs/ufs-provision.c b/drivers/scsi/ufs/ufs-provision.c index d84fb547..3930ccf6 100644 --- a/drivers/scsi/ufs/ufs-provision.c +++ b/drivers/scsi/ufs/ufs-provision.c @@ -6,13 +6,7 @@ #include "ufs-tegra.h" #ifdef CONFIG_DEBUG_FS -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -#include -#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) -#include -#else -#include -#endif +#include #define CHECK_NULL(expr) \ { \ diff --git a/drivers/scsi/ufs/ufs-provision.h b/drivers/scsi/ufs/ufs-provision.h index 470060ba..85a0b02a 100644 --- a/drivers/scsi/ufs/ufs-provision.h +++ b/drivers/scsi/ufs/ufs-provision.h @@ -7,13 +7,7 @@ #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -#include -#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) -#include -#else -#include -#endif +#include #ifdef CONFIG_DEBUG_FS #include diff --git a/drivers/scsi/ufs/ufs-tegra-common.c b/drivers/scsi/ufs/ufs-tegra-common.c index 5fb2269b..76e2455d 100644 --- a/drivers/scsi/ufs/ufs-tegra-common.c +++ b/drivers/scsi/ufs/ufs-tegra-common.c @@ -23,22 +23,10 @@ #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -#include -#include -#include -#include -#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) -#include -#include -#include -#include -#else -#include -#include -#include -#include -#endif +#include +#include +#include +#include #include "ufs-tegra.h" #include "ufs-provision.h" diff --git a/include/drivers-private/scsi/ufs/k516/ufshcd-pltfrm.h b/include/drivers-private/scsi/ufs/k516/ufshcd-pltfrm.h deleted file mode 100644 index c33e28ac..00000000 --- a/include/drivers-private/scsi/ufs/k516/ufshcd-pltfrm.h +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2015, The Linux Foundation. All rights reserved. - */ - -#ifndef UFSHCD_PLTFRM_H_ -#define UFSHCD_PLTFRM_H_ - -#include "ufshcd.h" - -#define UFS_PWM_MODE 1 -#define UFS_HS_MODE 2 - -struct ufs_dev_params { - u32 pwm_rx_gear; /* pwm rx gear to work in */ - u32 pwm_tx_gear; /* pwm tx gear to work in */ - u32 hs_rx_gear; /* hs rx gear to work in */ - u32 hs_tx_gear; /* hs tx gear to work in */ - u32 rx_lanes; /* number of rx lanes */ - u32 tx_lanes; /* number of tx lanes */ - u32 rx_pwr_pwm; /* rx pwm working pwr */ - u32 tx_pwr_pwm; /* tx pwm working pwr */ - u32 rx_pwr_hs; /* rx hs working pwr */ - u32 tx_pwr_hs; /* tx hs working pwr */ - u32 hs_rate; /* rate A/B to work in HS */ - u32 desired_working_mode; -}; - -int ufshcd_get_pwr_dev_param(struct ufs_dev_params *dev_param, - struct ufs_pa_layer_attr *dev_max, - struct ufs_pa_layer_attr *agreed_pwr); -void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param); -int ufshcd_pltfrm_init(struct platform_device *pdev, - const struct ufs_hba_variant_ops *vops); -void ufshcd_pltfrm_shutdown(struct platform_device *pdev); - -#endif /* UFSHCD_PLTFRM_H_ */ diff --git a/include/drivers-private/scsi/ufs/k61/ufshcd-pltfrm.h b/include/drivers-private/scsi/ufs/k61/ufshcd-pltfrm.h deleted file mode 100644 index c33e28ac..00000000 --- a/include/drivers-private/scsi/ufs/k61/ufshcd-pltfrm.h +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2015, The Linux Foundation. All rights reserved. - */ - -#ifndef UFSHCD_PLTFRM_H_ -#define UFSHCD_PLTFRM_H_ - -#include "ufshcd.h" - -#define UFS_PWM_MODE 1 -#define UFS_HS_MODE 2 - -struct ufs_dev_params { - u32 pwm_rx_gear; /* pwm rx gear to work in */ - u32 pwm_tx_gear; /* pwm tx gear to work in */ - u32 hs_rx_gear; /* hs rx gear to work in */ - u32 hs_tx_gear; /* hs tx gear to work in */ - u32 rx_lanes; /* number of rx lanes */ - u32 tx_lanes; /* number of tx lanes */ - u32 rx_pwr_pwm; /* rx pwm working pwr */ - u32 tx_pwr_pwm; /* tx pwm working pwr */ - u32 rx_pwr_hs; /* rx hs working pwr */ - u32 tx_pwr_hs; /* tx hs working pwr */ - u32 hs_rate; /* rate A/B to work in HS */ - u32 desired_working_mode; -}; - -int ufshcd_get_pwr_dev_param(struct ufs_dev_params *dev_param, - struct ufs_pa_layer_attr *dev_max, - struct ufs_pa_layer_attr *agreed_pwr); -void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param); -int ufshcd_pltfrm_init(struct platform_device *pdev, - const struct ufs_hba_variant_ops *vops); -void ufshcd_pltfrm_shutdown(struct platform_device *pdev); - -#endif /* UFSHCD_PLTFRM_H_ */ diff --git a/include/drivers-private/scsi/ufs/k515/ufshcd-pltfrm.h b/include/drivers-private/scsi/ufs/ufshcd-pltfrm.h similarity index 100% rename from include/drivers-private/scsi/ufs/k515/ufshcd-pltfrm.h rename to include/drivers-private/scsi/ufs/ufshcd-pltfrm.h diff --git a/include/drivers-private/scsi/ufs/ufshcd.h b/include/drivers-private/scsi/ufs/ufshcd.h new file mode 100644 index 00000000..351b8da1 --- /dev/null +++ b/include/drivers-private/scsi/ufs/ufshcd.h @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#include +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) +#include +#else +#include +#endif diff --git a/include/drivers-private/scsi/ufs/ufshci.h b/include/drivers-private/scsi/ufs/ufshci.h new file mode 100644 index 00000000..ee7c85a8 --- /dev/null +++ b/include/drivers-private/scsi/ufs/ufshci.h @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#include +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) +#include +#else +#include +#endif diff --git a/include/drivers-private/scsi/ufs/unipro.h b/include/drivers-private/scsi/ufs/unipro.h new file mode 100644 index 00000000..d97f57b6 --- /dev/null +++ b/include/drivers-private/scsi/ufs/unipro.h @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#include +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) +#include +#else +#include +#endif