Re: [PATCH v8 1/4] mfd: add support for Diolan DLN-2 devices
From: Johan Hovold
Date: Mon Oct 27 2014 - 10:40:18 EST
On Mon, Oct 27, 2014 at 03:21:10PM +0200, Octavian Purdila wrote:
> On Thu, Oct 23, 2014 at 6:16 PM, Johan Hovold <johan@xxxxxxxxxx> wrote:
> > On Wed, Oct 15, 2014 at 05:48:08PM +0300, Octavian Purdila wrote:
> > > +struct dln2_event_cb_entry {
> > > + struct list_head list;
> > > + u16 id;
> > > + struct platform_device *pdev;
> > > + dln2_event_cb_t callback;
> > > +};
> > > +
> > > +int dln2_register_event_cb(struct platform_device *pdev, u16 id,
> > > + dln2_event_cb_t rx_cb)
> > > +{
> > > + struct dln2_dev *dln2 = dev_get_drvdata(pdev->dev.parent);
> > > + struct dln2_event_cb_entry *i, *new_cb;
> >
> > Can you use a name which does not have the same suffix as the actual
> > callback function (i.e. "_cb"). Just call it "entry" or something.
> >
>
> OK.
>
> > > + unsigned long flags;
> > > + int ret = 0;
> > > +
> > > + new_cb = kmalloc(sizeof(*new_cb), GFP_KERNEL);
> >
> > Use kzalloc here.
>
> Why kzalloc? All of the fields are initialized below.
It's good practise to clear any data structure at allocation. The cost
is negligible.
> > > + if (!new_cb)
> > > + return -ENOMEM;
> > > +
> > > + new_cb->id = id;
> > > + new_cb->callback = rx_cb;
> > > + new_cb->pdev = pdev;
> > > +
> > > + spin_lock_irqsave(&dln2->event_cb_lock, flags);
> > > +
> > > + list_for_each_entry(i, &dln2->event_cb_list, list) {
> > > + if (i->id == id) {
> > > + ret = -EBUSY;
> > > + break;
> > > + }
> > > + }
> > > +
> > > + if (!ret)
> > > + list_add_rcu(&new_cb->list, &dln2->event_cb_list);
> > > +
> > > + spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
> > > +
> > > + if (ret)
> > > + kfree(new_cb);
> > > +
> > > + return ret;
> > > +}
> > > +EXPORT_SYMBOL(dln2_register_event_cb);
> > > + ret = mfd_add_hotplug_devices(dev, dln2_devs, ARRAY_SIZE(dln2_devs));
> >
> > So this now depends on 15bb4d6e8534 ("mfd: core: Add helper function to
> > register hotplug devices") in the MFD tree.
> >
> > Please mention what tree the patch is against in your cover letter (I
> > noticed you had rebased when it no longer applied to 3.17).
> >
> > You should drop the gpiolib patch now that v3.18-rc1 is out as well.
>
> This series is based against the Lee's for-mfd-next-v3.19 tree that
> does not yet contain the gpiolib patch.
Ok, but make sure to include that information in the cover letter.
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/