All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Karol Herbst <kherbst@redhat.com>
Cc: nouveau <nouveau@lists.freedesktop.org>, osalvador.vilardaga@gmail.com
Subject: Re: [Nouveau] [bug report] drm/nouveau/hwmon: Remove old code, add .write/.read operations
Date: Wed, 28 Apr 2021 10:59:37 +0300	[thread overview]
Message-ID: <20210428075937.GZ1959@kadam> (raw)
In-Reply-To: <CACO55tvrienoNTXmVeHnXHOEAMB0AsJdu-BexuXhe-8gMohhSg@mail.gmail.com>

On Wed, Apr 21, 2021 at 06:04:45PM +0200, Karol Herbst wrote:
> On Wed, Apr 21, 2021 at 3:57 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > Hello Oscar Salvador,
> >
> > The patch bfb96e4c344e: "drm/nouveau/hwmon: Remove old code, add
> > .write/.read operations" from May 18, 2017, leads to the following
> > static checker warning:
> >
> >     drivers/gpu/drm/nouveau/nouveau_hwmon.c:507 nouveau_in_read()
> >     warn: check sign expansion for '-19'
> >     drivers/gpu/drm/nouveau/nouveau_hwmon.c:510 nouveau_in_read()
> >     warn: check sign expansion for '-19'
> >
> > drivers/gpu/drm/nouveau/nouveau_hwmon.c
> >    488  static int
> >    489  nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)
> >    490  {
> >    491          struct drm_device *drm_dev = dev_get_drvdata(dev);
> >    492          struct nouveau_drm *drm = nouveau_drm(drm_dev);
> >    493          struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
> >    494          int ret;
> >    495
> >    496          if (!volt)
> >    497                  return -EOPNOTSUPP;
> >    498
> >    499          switch (attr) {
> >    500          case hwmon_in_input:
> >    501                  if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
> >    502                          return -EINVAL;
> >    503                  ret = nvkm_volt_get(volt);
> >    504                  *val = ret < 0 ? ret : (ret / 1000);
> >    505                  break;
> >    506          case hwmon_in_min:
> >    507                  *val = volt->min_uv > 0 ? (volt->min_uv / 1000) : -ENODEV;
> >
> > This is trying to set "*val = -ENODEV" but because "volt->min_uv" is
> > unsigned int it actually sets it to "*val = (unsigned int)-ENODEV".
> >
> > It's weird to me that this code doesn't return -ENODEV instead of
> > setting *val to it.
> >
> 
> ohh.. that might actually be a left over from the conversion we've
> done in the past. Thanks for pointing it out. Do you want to write the
> patch as well?

Sorry the delayed response.  I'm still not sure if this should return
-ENODEV or not.  Could you please fix it and give me a reported-by tag?

regards,
dan carpenter

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

  reply	other threads:[~2021-04-28  8:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 13:24 [Nouveau] [bug report] drm/nouveau/hwmon: Remove old code, add .write/.read operations Dan Carpenter
2021-04-21 16:04 ` Karol Herbst
2021-04-28  7:59   ` Dan Carpenter [this message]
2022-06-01  9:08   ` Dan Carpenter

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=20210428075937.GZ1959@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kherbst@redhat.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=osalvador.vilardaga@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.