* [PATCH 12/14] scsi: use printk_once
[not found] <1249847649-11631-1-git-send-email-marcin.slusarz@gmail.com>
@ 2009-08-09 19:54 ` Marcin Slusarz
2009-08-11 16:40 ` James Bottomley
0 siblings, 1 reply; 5+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
To: LKML; +Cc: James E.J. Bottomley, linux-scsi
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/53c700.c | 6 +-----
drivers/scsi/cxgb3i/cxgb3i_init.c | 7 +------
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index f5a9add..c5f4fa7 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -291,7 +291,6 @@ NCR_700_detect(struct scsi_host_template *tpnt,
__u8 *memory;
__u32 *script;
struct Scsi_Host *host;
- static int banner = 0;
int j;
if(tpnt->sdev_attrs == NULL)
@@ -385,10 +384,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
else
hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f;
hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0);
- if (banner == 0) {
- printk(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
- banner = 1;
- }
+ printk_once(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no,
hostdata->chip710 ? "53c710" :
(hostdata->fast ? "53c700-66" : "53c700"),
diff --git a/drivers/scsi/cxgb3i/cxgb3i_init.c b/drivers/scsi/cxgb3i/cxgb3i_init.c
index 042d9bc..8c9285f 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_init.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_init.c
@@ -43,12 +43,7 @@ static struct cxgb3_client t3c_client = {
*/
static void open_s3_dev(struct t3cdev *t3dev)
{
- static int vers_printed;
-
- if (!vers_printed) {
- printk(KERN_INFO "%s", version);
- vers_printed = 1;
- }
+ printk_once(KERN_INFO "%s", version);
cxgb3i_ddp_init(t3dev);
cxgb3i_sdev_add(t3dev, &t3c_client);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 12/14] scsi: use printk_once
2009-08-09 19:54 ` [PATCH 12/14] scsi: use printk_once Marcin Slusarz
@ 2009-08-11 16:40 ` James Bottomley
2009-08-11 16:46 ` Roland Dreier
2009-08-11 16:49 ` Joe Perches
0 siblings, 2 replies; 5+ messages in thread
From: James Bottomley @ 2009-08-11 16:40 UTC (permalink / raw)
To: Marcin Slusarz; +Cc: LKML, linux-scsi
On Sun, 2009-08-09 at 21:54 +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: linux-scsi@vger.kernel.org
> ---
> drivers/scsi/53c700.c | 6 +-----
> drivers/scsi/cxgb3i/cxgb3i_init.c | 7 +------
> 2 files changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
> index f5a9add..c5f4fa7 100644
> --- a/drivers/scsi/53c700.c
> +++ b/drivers/scsi/53c700.c
> @@ -291,7 +291,6 @@ NCR_700_detect(struct scsi_host_template *tpnt,
> __u8 *memory;
> __u32 *script;
> struct Scsi_Host *host;
> - static int banner = 0;
> int j;
>
> if(tpnt->sdev_attrs == NULL)
> @@ -385,10 +384,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
> else
> hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f;
> hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0);
> - if (banner == 0) {
> - printk(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
> - banner = 1;
> - }
> + printk_once(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
> printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no,
> hostdata->chip710 ? "53c710" :
> (hostdata->fast ? "53c700-66" : "53c700"),
> diff --git a/drivers/scsi/cxgb3i/cxgb3i_init.c b/drivers/scsi/cxgb3i/cxgb3i_init.c
> index 042d9bc..8c9285f 100644
> --- a/drivers/scsi/cxgb3i/cxgb3i_init.c
> +++ b/drivers/scsi/cxgb3i/cxgb3i_init.c
> @@ -43,12 +43,7 @@ static struct cxgb3_client t3c_client = {
> */
> static void open_s3_dev(struct t3cdev *t3dev)
> {
> - static int vers_printed;
> -
> - if (!vers_printed) {
> - printk(KERN_INFO "%s", version);
> - vers_printed = 1;
> - }
> + printk_once(KERN_INFO "%s", version);
There's really no point to this beyond code churn. Both patterns are
correct uses so conversion buys us nothing.
James
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 12/14] scsi: use printk_once
2009-08-11 16:40 ` James Bottomley
@ 2009-08-11 16:46 ` Roland Dreier
2009-08-11 16:50 ` James Bottomley
2009-08-11 16:49 ` Joe Perches
1 sibling, 1 reply; 5+ messages in thread
From: Roland Dreier @ 2009-08-11 16:46 UTC (permalink / raw)
To: James Bottomley; +Cc: Marcin Slusarz, LKML, linux-scsi
> > - static int vers_printed;
> > -
> > - if (!vers_printed) {
> > - printk(KERN_INFO "%s", version);
> > - vers_printed = 1;
> > - }
> > + printk_once(KERN_INFO "%s", version);
> There's really no point to this beyond code churn. Both patterns are
> correct uses so conversion buys us nothing.
It's a pretty small gain but I do think 6 lines -> 1 line does have value.
- R.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 12/14] scsi: use printk_once
2009-08-11 16:40 ` James Bottomley
2009-08-11 16:46 ` Roland Dreier
@ 2009-08-11 16:49 ` Joe Perches
1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2009-08-11 16:49 UTC (permalink / raw)
To: James Bottomley; +Cc: Marcin Slusarz, LKML, linux-scsi
On Tue, 2009-08-11 at 11:40 -0500, James Bottomley wrote:
> On Sun, 2009-08-09 at 21:54 +0200, Marcin Slusarz wrote:
> > --- a/drivers/scsi/cxgb3i/cxgb3i_init.c
> > +++ b/drivers/scsi/cxgb3i/cxgb3i_init.c
> > @@ -43,12 +43,7 @@ static struct cxgb3_client t3c_client = {
> > */
> > static void open_s3_dev(struct t3cdev *t3dev)
> > {
> > - static int vers_printed;
> > -
> > - if (!vers_printed) {
> > - printk(KERN_INFO "%s", version);
> > - vers_printed = 1;
> > - }
> > + printk_once(KERN_INFO "%s", version);
>
> There's really no point to this beyond code churn. Both patterns are
> correct uses so conversion buys us nothing.
Standards are for hacks. Stasis is the best policy.
Using patterns isn't worth the electron movement.
Code shortening and readability? Humbug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 12/14] scsi: use printk_once
2009-08-11 16:46 ` Roland Dreier
@ 2009-08-11 16:50 ` James Bottomley
0 siblings, 0 replies; 5+ messages in thread
From: James Bottomley @ 2009-08-11 16:50 UTC (permalink / raw)
To: Roland Dreier; +Cc: Marcin Slusarz, LKML, linux-scsi
On Tue, 2009-08-11 at 09:46 -0700, Roland Dreier wrote:
> > > - static int vers_printed;
> > > -
> > > - if (!vers_printed) {
> > > - printk(KERN_INFO "%s", version);
> > > - vers_printed = 1;
> > > - }
> > > + printk_once(KERN_INFO "%s", version);
>
> > There's really no point to this beyond code churn. Both patterns are
> > correct uses so conversion buys us nothing.
>
> It's a pretty small gain but I do think 6 lines -> 1 line does have value.
Not at the expense of churning the code base of marginal drivers.
I'm not entirely convinced this is a good pattern to begin with. If you
add too many patterns you're effectively developing an overly complex
development language and rule set. Even if I go with this on the basis
of readability (as you say, one line for six), then I still don't think
we should churn the code base to convert correct open coding to it; we
should just use it ongoing.
James
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-11 16:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1249847649-11631-1-git-send-email-marcin.slusarz@gmail.com>
2009-08-09 19:54 ` [PATCH 12/14] scsi: use printk_once Marcin Slusarz
2009-08-11 16:40 ` James Bottomley
2009-08-11 16:46 ` Roland Dreier
2009-08-11 16:50 ` James Bottomley
2009-08-11 16:49 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox