Message ID | 20231201150647.1307406-9-mathias.nyman@linux.intel.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xhci features for usb-next | expand |
From: Mathias Nyman > Sent: 01 December 2023 15:07 > > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Instead of doing custom calculations, use sizeof_field() macro. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> > --- > drivers/usb/host/xhci-dbgcap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c > index 779a564ad698..0c9fd61e9c5b 100644 > --- a/drivers/usb/host/xhci-dbgcap.c > +++ b/drivers/usb/host/xhci-dbgcap.c > @@ -374,7 +374,7 @@ static void xhci_dbc_eps_init(struct xhci_dbc *dbc) > > static void xhci_dbc_eps_exit(struct xhci_dbc *dbc) > { > - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); > + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); Isn't that just: memset(dpc->eps, 0, sizeof (dpc->eps)); perhaps better written as: memset(&dpc->epc, 0, sizeof (dpc->eps); Otherwise the existing code wouldn't make sense at all. David > } > > static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, > -- > 2.25.1 > - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Fri, Dec 01, 2023 at 05:31:52PM +0000, David Laight wrote: > From: Mathias Nyman > > Sent: 01 December 2023 15:07 ... > > - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); > > + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); > > Isn't that just: > memset(dpc->eps, 0, sizeof (dpc->eps)); > perhaps better written as: > memset(&dpc->epc, 0, sizeof (dpc->eps); Maybe... You can send a patch, so it gets tested for regressions! > Otherwise the existing code wouldn't make sense at all.
From: Andy Shevchenko > Sent: 01 December 2023 19:08 > > On Fri, Dec 01, 2023 at 05:31:52PM +0000, David Laight wrote: > > From: Mathias Nyman > > > Sent: 01 December 2023 15:07 > > ... > > > > - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); > > > + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); > > > > Isn't that just: > > memset(dpc->eps, 0, sizeof (dpc->eps)); > > perhaps better written as: > > memset(&dpc->epc, 0, sizeof (dpc->eps); > > Maybe... > You can send a patch, so it gets tested for regressions! Any patch I write will conflict with v2 of this series. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On 2.12.2023 17.50, David Laight wrote: > From: Andy Shevchenko >> Sent: 01 December 2023 19:08 >> >> On Fri, Dec 01, 2023 at 05:31:52PM +0000, David Laight wrote: >>> From: Mathias Nyman >>>> Sent: 01 December 2023 15:07 >> >> ... >> >>>> - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); >>>> + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); >>> >>> Isn't that just: >>> memset(dpc->eps, 0, sizeof (dpc->eps)); >>> perhaps better written as: >>> memset(&dpc->epc, 0, sizeof (dpc->eps); >> >> Maybe... >> You can send a patch, so it gets tested for regressions! > > Any patch I write will conflict with v2 of this series. > I'll drop this 8/19 patch as it's just a one liner cleanup that does no harm, but apparently doesn't really help either. David, I'll be happy to take a patch for this from you, but still need to run it through some testing I'll send v2 of this series Thanks Mathias
> I'll drop this 8/19 patch as it's just a one liner cleanup that does no > harm, but apparently doesn't really help either. > > David, I'll be happy to take a patch for this from you, but still need to > run it through some testing I'd just run objdump to check the constant is the same. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 779a564ad698..0c9fd61e9c5b 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -374,7 +374,7 @@ static void xhci_dbc_eps_init(struct xhci_dbc *dbc) static void xhci_dbc_eps_exit(struct xhci_dbc *dbc) { - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); + memset(dbc->eps, 0, sizeof_field(struct xhci_dbc, eps)); } static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring,