* [bug report] ptp: ocp: Add debugfs entry for timecard
@ 2022-03-16 11:15 Dan Carpenter
2022-03-16 11:16 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-03-16 11:15 UTC (permalink / raw)
To: jonathan.lemon; +Cc: kernel-janitors
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] ptp: ocp: Add debugfs entry for timecard
2022-03-16 11:15 [bug report] ptp: ocp: Add debugfs entry for timecard Dan Carpenter
@ 2022-03-16 11:16 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2022-03-16 11:16 UTC (permalink / raw)
To: jonathan.lemon; +Cc: kernel-janitors
Also:
drivers/ptp/ptp_ocp.c:3154 ptp_ocp_summary_show() warn: right shifting more than type allows 16 vs 16
regards,
dan carpenter
On Wed, Mar 16, 2022 at 02:15:46PM +0300, Dan Carpenter wrote:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-16 11:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-16 11:15 [bug report] ptp: ocp: Add debugfs entry for timecard Dan Carpenter
2022-03-16 11:16 ` Dan Carpenter
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.