+What: /sys/bus/platform/drivers/ufshcd/*/attributes/case_rough_temp
+Date: September 2021
+Contact: Avri Altman <avri.altman@xxxxxxx>
+Description: The device case rough temperature (bDeviceCaseRoughTemperature
+ attribute). It is termed "rough" due to the inherent inaccuracy
+ of the temperature sensor inside a semiconductor device,
+ e.g. +- 10 degrees centigrade error range.
+ allowable range is [-79..170].
+ The temperature readings are in decimal degrees Celsius.
+
+ Please note that the Tcase validity depends on the state of the
+ wExceptionEventControl attribute: it is up to the user to
+ verify that the applicable mask (TOO_HIGH_TEMP_EN, and / or
+ TOO_LOW_TEMP_EN) is set for the exception handling control.
+ This can be either done by ufs-bsg or ufs-debugfs.
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 5c405ff7b6ea..a9abe33c40e4 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -1047,6 +1047,86 @@ static inline bool ufshcd_is_wb_attrs(enum attr_idn idn)
idn <= QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE;
}
+static inline bool ufshcd_is_temp_attrs(enum attr_idn idn)
+{
+ return idn >= QUERY_ATTR_IDN_CASE_ROUGH_TEMP &&
+ idn <= QUERY_ATTR_IDN_LOW_TEMP_BOUND;
+}
+static bool ufshcd_case_temp_legal(struct ufs_hba *hba)\
+ ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+ QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &ee_mask);
+ ufshcd_rpm_put_sync(hba);