Re: [PATCH 3/5] watchdog: cleanup a bit omap_wdt.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 20 September 2008, Russell King - ARM Linux wrote:
> On Fri, Sep 19, 2008 at 05:41:44PM -0700, David Brownell wrote:
> > On Friday 19 September 2008, Felipe Balbi wrote:
> > >  static int omap_wdt_open(struct inode *inode, struct file *file)
> > >  {
> > > -       struct omap_wdt_dev *wdev;
> > > -       void __iomem *base;
> > > -       wdev = platform_get_drvdata(omap_wdt_dev);
> > > -       base = wdev->base;
> > > +       struct omap_wdt_dev *wdev = platform_get_drvdata(omap_wdt_dev);
> > > +       void __iomem *base = wdev->base;
> > > +
> > 
> > Oh, I see where "omap_wdt_dev" (global) gets used.  The normal
> > way to do stuff like that is using void* pointers placed in the
> > inode and file structures for exactly that purpose.
> 
> You don't have an inode or a file structure until open() is called -
> at which point it _is_ placed in file->private_data.  So this driver
> is doing the right thing.

Well, the conventional thing for misc drivers, at any rate.  In
various other drivers, inode->i_private is set up earlier, just
to avoid such a need for globals (or equivalent).

One could argue that this idiom is ugly ... and fix it by having
misc_open() in drivers/char/misc.c initialize i_private before
delegating to the miscdevice->fops->open().  Even just setting
it to the miscdevice pointer would suffice with this driver;
container_of(i_private, struct omap_wdt_dev, omap_wdt_miscdev)
would then return what get_drvdata() returns, sans global.

But that wouldn't be just cleaning up this watchdog.

= Dave


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux