All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: jonathan.lemon@gmail.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] ptp: ocp: Add debugfs entry for timecard
Date: Wed, 16 Mar 2022 14:15:46 +0300	[thread overview]
Message-ID: <20220316111546.GA4687@kili> (raw)

Hello Jonathan Lemon,

The patch f67bf662d2cf: "ptp: ocp: Add debugfs entry for timecard"
from Sep 14, 2021, leads to the following Smatch static checker
warning:

	drivers/ptp/ptp_ocp.c:3102 ptp_ocp_summary_show()
	warn: right shifting more than type allows 16 vs 16

drivers/ptp/ptp_ocp.c
    2969 static int
    2970 ptp_ocp_summary_show(struct seq_file *s, void *data)
    2971 {
    2972         struct device *dev = s->private;
    2973         struct ptp_system_timestamp sts;
    2974         u16 sma_val[4][2], ctrl, val;
                                    ^^^^
This "ctrl" variable should probably be a u32.

    2975         struct ts_reg __iomem *ts_reg;
    2976         struct timespec64 ts;
    2977         struct ptp_ocp *bp;
    2978         char *src, *buf;
    2979         bool on, map;
    2980         int i;
    2981 
    2982         buf = (char *)__get_free_page(GFP_KERNEL);
    2983         if (!buf)
    2984                 return -ENOMEM;
    2985 

[ snip ]

    3087 
    3088         if (bp->fw_cap & OCP_CAP_SIGNAL)
    3089                 for (i = 0; i < 4; i++)
    3090                         _signal_summary_show(s, bp, i);
    3091 
    3092         if (bp->fw_cap & OCP_CAP_FREQ)
    3093                 for (i = 0; i < 4; i++)
    3094                         _frequency_summary_show(s, i, bp->freq_in[i]);
    3095 
    3096         if (bp->irig_out) {
    3097                 ctrl = ioread32(&bp->irig_out->ctrl);

reads a u32

    3098                 on = ctrl & IRIG_M_CTRL_ENABLE;
    3099                 val = ioread32(&bp->irig_out->status);
    3100                 gpio_output_map(buf, bp, sma_val, 4);
    3101                 seq_printf(s, "%7s: %s, error: %d, mode %d, out: %s\n", "IRIG",
--> 3102                            on ? " ON" : "OFF", val, (ctrl >> 16), buf);
                                                              ^^^^^^^^^^
shifts to zero

    3103         }
    3104 
    3105         if (bp->irig_in) {
    3106                 on = ioread32(&bp->irig_in->ctrl) & IRIG_S_CTRL_ENABLE;
    3107                 val = ioread32(&bp->irig_in->status);
    3108                 gpio_input_map(buf, bp, sma_val, 4, NULL);
    3109                 seq_printf(s, "%7s: %s, error: %d, src: %s\n", "IRIG in",
    3110                            on ? " ON" : "OFF", val, buf);
    3111         }
    3112 

regards,
dan carpenter

             reply	other threads:[~2022-03-16 11:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 11:15 Dan Carpenter [this message]
2022-03-16 11:16 ` [bug report] ptp: ocp: Add debugfs entry for timecard 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=20220316111546.GA4687@kili \
    --to=dan.carpenter@oracle.com \
    --cc=jonathan.lemon@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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.