lkml.org 
[lkml]   [2014]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] can: kvaser_usb: Add support for the Usbcan-II family
    On Sun, Dec 28, 2014 at 10:51:34PM +0100, Olivier Sobrie wrote:
    [...]
    > > > >
    > > > > + if (LEAF_PRODUCT_ID(id->idProduct)) {
    > > > > + dev->family = KVASER_LEAF;
    > > > > + dev->max_channels = LEAF_MAX_NET_DEVICES;
    > > > > + } else if (USBCAN_PRODUCT_ID(id->idProduct)) {
    > > > > + dev->family = KVASER_USBCAN;
    > > > > + dev->max_channels = USBCAN_MAX_NET_DEVICES;
    > > > > + } else {
    > > > > + dev_err(&intf->dev, "Product ID (%d) does not belong to any "
    > > > > + "known Kvaser USB family", id->idProduct);
    > > > > + return -ENODEV;
    > > > > + }
    > > > > +
    > > >
    > > > Is it really required to keep max_channels in the kvaser_usb structure?
    > > > If I looked correctly, you use this variable as a replacement for
    > > > MAX_NET_DEVICES in the code and MAX_NET_DEVICES is only used in probe
    > > > and disconnect functions. I think it can even be replaced by nchannels
    > > > in the disconnect path. So I also think that it don't need to be in the
    > > > kvaser_usb structure.
    > > >
    > >
    > > hmmm.. given the current state of error arbitration explained
    > > above, where I cannot accept a dev->nchannels > 2, I guess we
    > > have two options:
    > >
    > > a) Remove max_channels, and hardcode the channels count
    > > correctness logic as follows:
    > >
    > > dev->nchannels = msg.u.cardinfo.nchannels;
    > > if ((dev->family == USBCAN && dev->nchannels > USBCAN_MAX_NET_DEVICES)
    > > || (dev->family == LEAF && dev->nchannels > LEAF_MAX_NET_DEVICES))
    > > return -EINVAL
    > >
    > > b) Leave max_channels in 'struct kvaser_usb' as is.
    > >
    > > I personally prefer the solution at 'b)' but I can do it as
    > > in 'a)' if you prefer :-)
    >
    > Keeping max_channels in the kvaser_usb structure is useless because it
    > is only used in one function that is called in the probe function.
    >
    > I would prefer to have:
    > if (dev->nchannels > MAX_NET_DEVICES)
    > return -EINVAL
    >
    > if ((dev->family == USBCAN) &&
    > (dev->nchannels > MAX_USBCAN_NET_DEVICES))
    > return -EINVAL
    >
    > You can remove LEAF_MAX_NET_DEVICES which is not used, keep
    > MAX_NET_DEVICES equals to 3 and remove the MAX() macro.
    > The test specific to the USBCAN family can eventually be moved in the
    > kvaser_usb_probe() function.
    >

    Quite nice, will do it that way in v3.

    Regards,
    Darwish


    \
     
     \ /
      Last update: 2014-12-30 17:01    [W:6.756 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site