From: David Brownell <david-b@pacbell.net>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Felipe Balbi <felipe.balbi@nokia.com>,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
Tony Lindgren <tony@atomide.com>,
Wim Van Sebroeck <wim@iguana.be>,
Andrew Morton <akpm@linux-foundation.org>,
"George G. Davis" <gdavis@mvista.com>
Subject: Re: [PATCH 3/5] watchdog: cleanup a bit omap_wdt.c
Date: Sat, 20 Sep 2008 08:32:14 -0700 [thread overview]
Message-ID: <200809200832.15440.david-b@pacbell.net> (raw)
In-Reply-To: <20080920081326.GB11114@flint.arm.linux.org.uk>
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: David Brownell <david-b@pacbell.net>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Felipe Balbi <felipe.balbi@nokia.com>,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
Tony Lindgren <tony@atomide.com>,
Wim Van Sebroeck <wim@iguana.be>,
Andrew Morton <akpm@linux-foundation.org>,
"George G. Davis" <gdavis@mvista.com>
Subject: Re: [PATCH 3/5] watchdog: cleanup a bit omap_wdt.c
Date: Sat, 20 Sep 2008 08:32:14 -0700 [thread overview]
Message-ID: <200809200832.15440.david-b@pacbell.net> (raw)
In-Reply-To: <20080920081326.GB11114@flint.arm.linux.org.uk>
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
next prev parent reply other threads:[~2008-09-20 15:32 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-19 10:32 [PATCH 0/5] omap watchdog updaes Felipe Balbi
2008-09-19 10:32 ` [PATCH 1/5] watchdog: sync linux-omap changes Felipe Balbi
2008-09-19 10:32 ` [PATCH 2/5] watchdog: another ioremap() fix Felipe Balbi
2008-09-19 10:32 ` [PATCH 3/5] watchdog: cleanup a bit omap_wdt.c Felipe Balbi
2008-09-19 10:32 ` [PATCH 4/5] watchdog: move omap_wdt.h to include/linux/watchdog Felipe Balbi
2008-09-19 10:32 ` [PATCH 5/5] watchdog: introduce platform_data and remove cpu conditional code Felipe Balbi
2008-09-19 19:04 ` Russell King - ARM Linux
2008-09-19 21:33 ` Felipe Balbi
2008-09-19 22:51 ` Russell King - ARM Linux
2008-09-20 15:03 ` Wim Van Sebroeck
2008-09-20 5:48 ` Wim Van Sebroeck
2008-09-19 10:56 ` [PATCH 4/5] watchdog: move omap_wdt.h to include/linux/watchdog Alan Cox
2008-09-19 10:56 ` Alan Cox
2008-09-19 11:06 ` Felipe Balbi
2008-09-19 12:52 ` Alan Cox
2008-09-20 0:41 ` [PATCH 3/5] watchdog: cleanup a bit omap_wdt.c David Brownell
2008-09-20 0:41 ` David Brownell
2008-09-20 8:13 ` Russell King - ARM Linux
2008-09-20 15:32 ` David Brownell [this message]
2008-09-20 15:32 ` David Brownell
2008-09-20 16:11 ` Russell King - ARM Linux
2008-09-20 16:11 ` Russell King - ARM Linux
2008-09-20 17:18 ` David Brownell
2008-09-20 18:00 ` Russell King - ARM Linux
2008-09-21 18:41 ` Tony Lindgren
2008-09-22 2:01 ` David Brownell
2008-09-22 1:45 ` David Brownell
2008-09-22 7:59 ` Russell King - ARM Linux
2008-09-22 9:30 ` Tony Lindgren
2008-09-20 17:01 ` Alan Cox
2008-09-19 22:40 ` [PATCH 1/5] watchdog: sync linux-omap changes Russell King - ARM Linux
2008-09-20 0:20 ` David Brownell
2008-09-20 0:39 ` David Brownell
2008-09-20 0:39 ` David Brownell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200809200832.15440.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=felipe.balbi@nokia.com \
--cc=gdavis@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=tony@atomide.com \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.