lkml.org 
[lkml]   [2021]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 1/2] scsi: ufs: Probe for temperature notification support
From
Date
On 9/8/21 11:34 PM, Avri Altman wrote:
> +static bool ufs_temp_enabled(struct ufs_hba *hba, struct ufs_hwmon_data *data)
> +{
> + u32 ee_mask;
> +
> + if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
> + QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &ee_mask))
> + return false;
> +
> + return (data->mask & ee_mask & MASK_EE_TOO_HIGH_TEMP) ||
> + (data->mask & ee_mask & MASK_EE_TOO_LOW_TEMP);
> +}

The above function uses data->mask but not data so it's probably better to pass
data->mask directly as the second argument.

> +static bool ufs_temp_valid(struct ufs_hba *hba, struct ufs_hwmon_data *data,
> + enum attr_idn idn, u32 value)
> +{
> + return (idn == QUERY_ATTR_IDN_CASE_ROUGH_TEMP && value >= 1 &&
> + value <= 250 && ufs_temp_enabled(hba, data)) ||
> + (idn == QUERY_ATTR_IDN_HIGH_TEMP_BOUND && value >= 100 &&
> + value <= 250) ||
> + (idn == QUERY_ATTR_IDN_LOW_TEMP_BOUND && value >= 1 &&
> + value <= 80);
> +}

Same comment for this function - if the above comment is addressed 'mask' can be
passed as an argument instead of 'data'.

> +static int ufs_get_temp(struct ufs_hba *hba, struct ufs_hwmon_data *data,
> + enum attr_idn idn)
> +{
> + u32 value;
> +
> + if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, idn, 0, 0,
> + &value))
> + return 0;
> +
> + if (ufs_temp_valid(hba, data, idn, value))
> + return value - 80;
> +
> + return 0;
> +}

Same comment here.

> +void ufs_hwmon_remove(struct ufs_hba *hba)
> +{
> + if (hba->hwmon_device) {
> + struct ufs_hwmon_data *data =
> + dev_get_drvdata(hba->hwmon_device);
> +
> + hwmon_device_unregister(hba->hwmon_device);
> + hba->hwmon_device = NULL;
> + kfree(data);
> + }
> +}

Please use the "early return" style since that is the most widely used style
in the Linux kernel (if (!hba->hwmon_device) return).

Thanks,

Bart.

\
 
 \ /
  Last update: 2021-09-09 18:27    [W:0.089 / U:1.652 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site