RE: [PATCH v5 1/2] scsi: ufs: Probe for temperature notification support
From: Avri Altman
Date: Tue Sep 14 2021 - 16:02:43 EST
> > +static int ufs_read_temp_enable(struct ufs_hba *hba, u8 mask, long
> > +*val) {
> > + u32 ee_mask;
> > + int err = 0;
>
> Unnecessary initialization
Done.
>
> > +
> > + err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
> QUERY_ATTR_IDN_EE_CONTROL, 0, 0,
> > + &ee_mask);
> > + if (err)
> > + return err;
> > +
> > + *val = (mask & ee_mask & MASK_EE_TOO_HIGH_TEMP) || (mask &
> > + ee_mask & MASK_EE_TOO_LOW_TEMP);
> > +
> > + return 0;
> > +}
> > +
> > +static int ufs_get_temp(struct ufs_hba *hba, enum attr_idn idn, long
> > +*val) {
> > + u32 value;
> > + int err = 0;
Here as well.
> > +
> > + err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, idn,
> 0, 0, &value);
> > + if (err)
> > + return err;
> > +
> > + if (value == 0)
> > + return -ENODATA;
> > +
> > + *val = ((long)value - 80) * MILLIDEGREE_PER_DEGREE;
> > +
> > + return 0;
> > +}
> > +
> > +static int ufs_hwmon_read(struct device *dev, enum
> hwmon_sensor_types type, u32 attr, int channel,
> > + long *val)
> > +{
> > + struct ufs_hwmon_data *data = dev_get_drvdata(dev);
> > + struct ufs_hba *hba = data->hba;
> > + int err = 0;
>
> Unnecesaary initialization
Done.
>
> > +
> > + if (type != hwmon_temp)
> > + return 0;
> > +
> > + down(&hba->host_sem);
> > +
> > + if (!ufshcd_is_user_access_allowed(hba)) {
> > + up(&hba->host_sem);
> > + return -EBUSY;
> > + }
> > +
> > + ufshcd_rpm_get_sync(hba);
> > +
> > + switch (attr) {
> > + case hwmon_temp_enable:
> > + err = ufs_read_temp_enable(hba, data->mask, val);
>
> extra space before 'err ='
Done.