Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread Doug Ledford
On Fri, 2007-02-16 at 10:50 -0800, Andrew Morton wrote:

> Me no understand.
> 
> If you take the specific example of
> 
> void
> ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
>u_int period, u_int offset, u_int ppr_options,
>u_int type, int paused)
> 
> then if is crufty, inappropriate and wrong that `paused' is a scalar type.

Although you picked a code segment out of the modern aic7xxx, there is a
matching similar one in aic7xxx_old.  Now, in all fairness, I was at one
point playing with a much more preemptable model for that driver that
allowed nested pauses, at which point the value of pause would have made
sense to be scalar, but that was a *long* time ago.

>  
> It's just not true or sensible that the code is written so that `paused'
> can take a value of seventy eight.  It _is_ a boolean.  It is a truth
> value.  Declaring it as such in the source is all goodness.  Passing the
> value `true' into calls to this function improve readability over passing
> "1".

Hence the reason for the original upper case TRUE/FALSE.  I have to
admit, I don't really like the lower case true/false, it looks like a
variable that can be assigned, thereby changing the implementation of
the function call when in fact each calling location is hard coding a
constant.  But, that's just me and my crufty old C that differentiates
between hard coded things and variables via case.

> So I don't agree with (or understand) your objections.  But I can certainly
> understand reluctance to merge a large-but-minor, do-nothing-much patch into
> a large and not-very-maintained driver.

Hehehe...and here I was thinking of factoring that thing into files and
actually bringing it into the current century.

-- 
Doug Ledford <[EMAIL PROTECTED]>
  GPG KeyID: CFBFF194
  http://people.redhat.com/dledford

Infiniband specific RPMs available at
  http://people.redhat.com/dledford/Infiniband


signature.asc
Description: This is a digitally signed message part


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread Richard Knutsson

James Bottomley wrote:

On Fri, 2007-02-16 at 19:04 +0100, Richard Knutsson wrote:
  

James Bottomley wrote:


On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
  
  

Given that we now have a standard kernel-wide, c99-friendly way of
expressing true and false, I'd suggest that this decision can be revisited.

Because a "true" is significantly more meaningful (and hence readable)
thing than a bare "1".



OK, I'm really not happy with doing this for three reasons:

1. It's inviting huge amounts of driver churn changing bitfields to
booleans
  
  

Have been some work done already. Has there been any problems?



There's always an issue when two people work on the same driver ... it
causes patch conflicts, which is why we try to avoid it where we can.
  

But it is (hopefully) a one-time change.

2. I do find it to be a readability issue.  Like most driver writers,
I'm used to register layouts, and those are simple bitfields, so I don't
tend to think true and false, I think 1 and 0.
  
  
It is a fundamental difference between an integer and a boolean. Have 
you seen anyone trying to do "bool var = true + true;"? ;)



I don't quite see how this is relevant to the readability issue?
  

Your "simple bitfields" :)
But on the note of readability; there is in no way any constraints to 
only use 'false'/'true'. Right now I'm converting some files who already 
uses FALSE/TRUE and may change 0/1 for consitency.
But I think it all boils down to what people are used to (I don't think 
there are any C++/Java-developers who complains about boolean and 
false/true). I am not too concerned about 0/1 being used or false/true, 
but the proper use of booleans and values.
  

3. Having a different, special, type for single bit bitfields (while
still using u for multi bit bitfields) is asking for confusion, and
hence trouble at the driver level.
  
  

I don't think a boolean should be view as a single bit bitfield. Ex:
u8 a:1;
...
int b = 4 + a;
is obviously not a boolean, while:
u8 a:1;
...
if (a)
is, and a should be "bool a:1;" (imho)



This again, doesn't really address the argument.  I'm saying I'd rather
not have confusion over what types to use in the driver.  You're saying
that if you only check the value for truth or falsehood it should be a
boolean.  That's actually worse than I was anticipating because you're
now saying that single bit bitfields may or may not be booleans
depending on use.  This looks like worse potential for confusion than
before.
  

Actually I find it to be simpler. Which would you chose?:
u8 a:1;
or
int a:1;
for a value? But if 'a' is a statement, then we just use:
bool a:1 (if the size of the variable is of relevance, otherwise just 
"bool a"). (You know what the variables are going to be used for when 
declaring them, right??)
Btw, how do you know if "a += 1" is just used to flip 'a's value or if 
it is a bug (in the case of boolean)?


Richard "come over to the dark side" Knutsson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread Andrew Morton
On Fri, 16 Feb 2007 12:42:27 -0600 James Bottomley <[EMAIL PROTECTED]> wrote:

> On Fri, 2007-02-16 at 10:34 -0800, Andrew Morton wrote:
> > On Fri, 16 Feb 2007 10:42:12 -0600 James Bottomley <[EMAIL PROTECTED]> 
> > wrote:
> > 
> > > On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
> > > > Given that we now have a standard kernel-wide, c99-friendly way of
> > > > expressing true and false, I'd suggest that this decision can be 
> > > > revisited.
> > > > 
> > > > Because a "true" is significantly more meaningful (and hence readable)
> > > > thing than a bare "1".
> > > 
> > > OK, I'm really not happy with doing this for three reasons:
> > > 
> > > 1. It's inviting huge amounts of driver churn changing bitfields to
> > > booleans
> > > 
> > > 2. I do find it to be a readability issue.  Like most driver writers,
> > > I'm used to register layouts, and those are simple bitfields, so I don't
> > > tend to think true and false, I think 1 and 0.
> > > 
> > > 3. Having a different, special, type for single bit bitfields (while
> > > still using u for multi bit bitfields) is asking for confusion, and
> > > hence trouble at the driver level.
> > > 
> > 
> > Confused.  The patch changes TRUE to true and FALSE to false.  The code
> > wasn't using bitfields before and isn't using them afterwards.  I wouldn't
> > expect there to be any change in generated code.
> 
> Sorry, I was addressing the general idea of using booleans in drivers.
> 
> > All it's doing is replacing the driver's private TRUE/FALSE with the
> > kernel-wide ones.
> 
> I already addressed that one ... I prefer bare 0 and 1.  However, if the
> driver writer wants to use TRUE/FALSE, I won't specifically reject it.
> I really don't like the lower case true/false.
> 

Me no understand.

If you take the specific example of

void
ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
 u_int period, u_int offset, u_int ppr_options,
 u_int type, int paused)

then if is crufty, inappropriate and wrong that `paused' is a scalar type. 
It's just not true or sensible that the code is written so that `paused'
can take a value of seventy eight.  It _is_ a boolean.  It is a truth
value.  Declaring it as such in the source is all goodness.  Passing the
value `true' into calls to this function improve readability over passing
"1".

So I don't agree with (or understand) your objections.  But I can certainly
understand reluctance to merge a large-but-minor, do-nothing-much patch into
a large and not-very-maintained driver.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread James Bottomley
On Fri, 2007-02-16 at 10:34 -0800, Andrew Morton wrote:
> On Fri, 16 Feb 2007 10:42:12 -0600 James Bottomley <[EMAIL PROTECTED]> wrote:
> 
> > On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
> > > Given that we now have a standard kernel-wide, c99-friendly way of
> > > expressing true and false, I'd suggest that this decision can be 
> > > revisited.
> > > 
> > > Because a "true" is significantly more meaningful (and hence readable)
> > > thing than a bare "1".
> > 
> > OK, I'm really not happy with doing this for three reasons:
> > 
> > 1. It's inviting huge amounts of driver churn changing bitfields to
> > booleans
> > 
> > 2. I do find it to be a readability issue.  Like most driver writers,
> > I'm used to register layouts, and those are simple bitfields, so I don't
> > tend to think true and false, I think 1 and 0.
> > 
> > 3. Having a different, special, type for single bit bitfields (while
> > still using u for multi bit bitfields) is asking for confusion, and
> > hence trouble at the driver level.
> > 
> 
> Confused.  The patch changes TRUE to true and FALSE to false.  The code
> wasn't using bitfields before and isn't using them afterwards.  I wouldn't
> expect there to be any change in generated code.

Sorry, I was addressing the general idea of using booleans in drivers.

> All it's doing is replacing the driver's private TRUE/FALSE with the
> kernel-wide ones.

I already addressed that one ... I prefer bare 0 and 1.  However, if the
driver writer wants to use TRUE/FALSE, I won't specifically reject it.
I really don't like the lower case true/false.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread Andrew Morton
On Fri, 16 Feb 2007 10:42:12 -0600 James Bottomley <[EMAIL PROTECTED]> wrote:

> On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
> > Given that we now have a standard kernel-wide, c99-friendly way of
> > expressing true and false, I'd suggest that this decision can be revisited.
> > 
> > Because a "true" is significantly more meaningful (and hence readable)
> > thing than a bare "1".
> 
> OK, I'm really not happy with doing this for three reasons:
> 
> 1. It's inviting huge amounts of driver churn changing bitfields to
> booleans
> 
> 2. I do find it to be a readability issue.  Like most driver writers,
> I'm used to register layouts, and those are simple bitfields, so I don't
> tend to think true and false, I think 1 and 0.
> 
> 3. Having a different, special, type for single bit bitfields (while
> still using u for multi bit bitfields) is asking for confusion, and
> hence trouble at the driver level.
> 

Confused.  The patch changes TRUE to true and FALSE to false.  The code
wasn't using bitfields before and isn't using them afterwards.  I wouldn't
expect there to be any change in generated code.

All it's doing is replacing the driver's private TRUE/FALSE with the
kernel-wide ones.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread James Bottomley
On Fri, 2007-02-16 at 19:04 +0100, Richard Knutsson wrote:
> James Bottomley wrote:
> > On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
> >   
> >> Given that we now have a standard kernel-wide, c99-friendly way of
> >> expressing true and false, I'd suggest that this decision can be revisited.
> >>
> >> Because a "true" is significantly more meaningful (and hence readable)
> >> thing than a bare "1".
> >> 
> >
> > OK, I'm really not happy with doing this for three reasons:
> >
> > 1. It's inviting huge amounts of driver churn changing bitfields to
> > booleans
> >   
> Have been some work done already. Has there been any problems?

There's always an issue when two people work on the same driver ... it
causes patch conflicts, which is why we try to avoid it where we can.

> > 2. I do find it to be a readability issue.  Like most driver writers,
> > I'm used to register layouts, and those are simple bitfields, so I don't
> > tend to think true and false, I think 1 and 0.
> >   
> It is a fundamental difference between an integer and a boolean. Have 
> you seen anyone trying to do "bool var = true + true;"? ;)

I don't quite see how this is relevant to the readability issue?

> > 3. Having a different, special, type for single bit bitfields (while
> > still using u for multi bit bitfields) is asking for confusion, and
> > hence trouble at the driver level.
> >   
> I don't think a boolean should be view as a single bit bitfield. Ex:
> u8 a:1;
> ...
> int b = 4 + a;
> is obviously not a boolean, while:
> u8 a:1;
> ...
> if (a)
> is, and a should be "bool a:1;" (imho)

This again, doesn't really address the argument.  I'm saying I'd rather
not have confusion over what types to use in the driver.  You're saying
that if you only check the value for truth or falsehood it should be a
boolean.  That's actually worse than I was anticipating because you're
now saying that single bit bitfields may or may not be booleans
depending on use.  This looks like worse potential for confusion than
before.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread Richard Knutsson

James Bottomley wrote:

On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
  

Given that we now have a standard kernel-wide, c99-friendly way of
expressing true and false, I'd suggest that this decision can be revisited.

Because a "true" is significantly more meaningful (and hence readable)
thing than a bare "1".



OK, I'm really not happy with doing this for three reasons:

1. It's inviting huge amounts of driver churn changing bitfields to
booleans
  

Have been some work done already. Has there been any problems?

2. I do find it to be a readability issue.  Like most driver writers,
I'm used to register layouts, and those are simple bitfields, so I don't
tend to think true and false, I think 1 and 0.
  
It is a fundamental difference between an integer and a boolean. Have 
you seen anyone trying to do "bool var = true + true;"? ;)

3. Having a different, special, type for single bit bitfields (while
still using u for multi bit bitfields) is asking for confusion, and
hence trouble at the driver level.
  

I don't think a boolean should be view as a single bit bitfield. Ex:
u8 a:1;
...
int b = 4 + a;
is obviously not a boolean, while:
u8 a:1;
...
if (a)
is, and a should be "bool a:1;" (imho)


Richard Knutsson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-16 Thread James Bottomley
On Mon, 2007-02-12 at 12:27 -0800, Andrew Morton wrote:
> Given that we now have a standard kernel-wide, c99-friendly way of
> expressing true and false, I'd suggest that this decision can be revisited.
> 
> Because a "true" is significantly more meaningful (and hence readable)
> thing than a bare "1".

OK, I'm really not happy with doing this for three reasons:

1. It's inviting huge amounts of driver churn changing bitfields to
booleans

2. I do find it to be a readability issue.  Like most driver writers,
I'm used to register layouts, and those are simple bitfields, so I don't
tend to think true and false, I think 1 and 0.

3. Having a different, special, type for single bit bitfields (while
still using u for multi bit bitfields) is asking for confusion, and
hence trouble at the driver level.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-12 Thread Andrew Morton
> On Sat, 10 Feb 2007 12:27:42 -0600 James Bottomley <[EMAIL PROTECTED]> wrote:
> When discussion about TRUE and FALSE came up a long time a go in the
> context of the mid layer we agreed to strip the defined constants out of
> that code and just go with 1 and 0 inline ... because the code was
> pretty much being rewritten.  We also decided to encourage but not force
> the driver writers simply to use 1 and 0 as well ... a lot of people are
> deeply wedded to the TRUE and FALSE defines, it turned out.

Given that we now have a standard kernel-wide, c99-friendly way of
expressing true and false, I'd suggest that this decision can be revisited.

Because a "true" is significantly more meaningful (and hence readable)
thing than a bare "1".
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-10 Thread Richard Knutsson

James Bottomley wrote:

On Sat, 2007-02-10 at 18:46 +0100, Richard Knutsson wrote:
  

Convert:
FALSE -> false
TRUE  -> true



Actually, downcasing true and false in this driver is pretty much a
retrograde step.  The reason for their being uppercased is that they
represent constants (and uppercase is the traditional defined constant
specifier).

When discussion about TRUE and FALSE came up a long time a go in the
context of the mid layer we agreed to strip the defined constants out of
that code and just go with 1 and 0 inline ... because the code was
pretty much being rewritten.  We also decided to encourage but not force
the driver writers simply to use 1 and 0 as well ... a lot of people are
deeply wedded to the TRUE and FALSE defines, it turned out.
  
Btw, is this just for aic7xxx_old and not aic7xxx? Is it going to be 
replaced? In that case, I will just leave it alone.


Richard Knutsson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-10 Thread Richard Knutsson

James Bottomley wrote:

On Sat, 2007-02-10 at 18:46 +0100, Richard Knutsson wrote:
  

Convert:
FALSE -> false
TRUE  -> true



Actually, downcasing true and false in this driver is pretty much a
retrograde step.  The reason for their being uppercased is that they
represent constants (and uppercase is the traditional defined constant
specifier).
  
I would argue that 'false' and 'true' are values and not constants, but 
further more C99 is defining them in lowercase (stdbool.h).

When discussion about TRUE and FALSE came up a long time a go in the
context of the mid layer we agreed to strip the defined constants out of
that code and just go with 1 and 0 inline ... because the code was
pretty much being rewritten.  We also decided to encourage but not force
the driver writers simply to use 1 and 0 as well ... a lot of people are
deeply wedded to the TRUE and FALSE defines, it turned out.
  
As I have expressed before, I don't understand why people seem to 
dislike 'false'/'true' but anyway, since you seem to approve booleans, 
would it be possible to convert the obvious variables/functions into 
boolean-type?


Richard Knutsson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] drivers/scsi/aic7xxx_old: Convert to generic boolean-values

2007-02-10 Thread James Bottomley
On Sat, 2007-02-10 at 18:46 +0100, Richard Knutsson wrote:
> Convert:
> FALSE -> false
> TRUE  -> true

Actually, downcasing true and false in this driver is pretty much a
retrograde step.  The reason for their being uppercased is that they
represent constants (and uppercase is the traditional defined constant
specifier).

When discussion about TRUE and FALSE came up a long time a go in the
context of the mid layer we agreed to strip the defined constants out of
that code and just go with 1 and 0 inline ... because the code was
pretty much being rewritten.  We also decided to encourage but not force
the driver writers simply to use 1 and 0 as well ... a lot of people are
deeply wedded to the TRUE and FALSE defines, it turned out.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/