LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Avri Altman <avri.altman@wdc.com>,
"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>,
Bean Huo <beanhuo@micron.com>, Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH v2 1/2] scsi: ufs: Probe for temperature notification support
Date: Thu, 9 Sep 2021 09:26:59 -0700 [thread overview]
Message-ID: <1b31a30a-cf2d-240c-78c1-ff348178f259@acm.org> (raw)
In-Reply-To: <20210909063444.22407-2-avri.altman@wdc.com>
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.
next prev parent reply other threads:[~2021-09-09 16:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 6:34 [PATCH v2 0/2] Add " Avri Altman
2021-09-09 6:34 ` [PATCH v2 1/2] scsi: ufs: Probe for " Avri Altman
2021-09-09 16:26 ` Bart Van Assche [this message]
2021-09-10 15:58 ` Avri Altman
2021-09-09 16:51 ` Guenter Roeck
2021-09-10 16:13 ` Avri Altman
2021-09-09 6:34 ` [PATCH v2 2/2] scsi: ufs: Add temperature notification exception handling Avri Altman
2021-09-09 16:54 ` Guenter Roeck
2021-09-10 16:32 ` Avri Altman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b31a30a-cf2d-240c-78c1-ff348178f259@acm.org \
--to=bvanassche@acm.org \
--cc=adrian.hunter@intel.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=martin.petersen@oracle.com \
--subject='Re: [PATCH v2 1/2] scsi: ufs: Probe for temperature notification support' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).