Subject: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup


Hi!

generic ATAPI hit #1 (rather trivial cleanup) against 2.5.22:

- move generic ATAPI structs from ide/ide-floppy.c
and ide/ide-tape.c to include/atapi.h
(this has a nice side effect of making ide-tape
a bit more endianness aware)

- also move generic ATAPI command's defines to atapi.h

- remove IDEFLOPPY_MIN/MAX() macros, use generic ones

- add #ifndef __LINUX_ATAPI_H_ blabla to atapi.h
to prevent including it more than once


should apply cleanly to 2.5.23
--
Bartlomiej Zolnierkiewicz


Attachments:
atapi-1.diff (44.49 kB)

2002-06-20 05:42:55

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:

Looks pretty good in general, just one minor detail:

> +
> +/*
> + * ATAPI packet commands.
> + */
> +#define ATAPI_FORMAT_UNIT_CMD 0x04
> +#define ATAPI_INQUIRY_CMD 0x12

[snip]

We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
variant (and I think the _CMD post fixing is silly, anyone familiar with
this is going to know what ATAPI_WRITE10 means just fine)

Same for request_sense, that is already generalized in cdrom.h as well.

--
Jens Axboe

2002-06-20 09:16:24

by Martin Dalecki

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

U?ytkownik Jens Axboe napisa?:
> On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
>
> Looks pretty good in general, just one minor detail:
>
>
>>+
>>+/*
>>+ * ATAPI packet commands.
>>+ */
>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
>>+#define ATAPI_INQUIRY_CMD 0x12
>
>
> [snip]
>
> We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
> that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
> variant (and I think the _CMD post fixing is silly, anyone familiar with
> this is going to know what ATAPI_WRITE10 means just fine)
>
> Same for request_sense, that is already generalized in cdrom.h as well.

I wonder what FreeBSD is using here? I see no need for invention at
this place.

2002-06-20 09:20:05

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

On Thu, Jun 20 2002, Martin Dalecki wrote:
> U?ytkownik Jens Axboe napisa?:
> >On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
> >
> >Looks pretty good in general, just one minor detail:
> >
> >
> >>+
> >>+/*
> >>+ * ATAPI packet commands.
> >>+ */
> >>+#define ATAPI_FORMAT_UNIT_CMD 0x04
> >>+#define ATAPI_INQUIRY_CMD 0x12
> >
> >
> >[snip]
> >
> >We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
> >that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
> >variant (and I think the _CMD post fixing is silly, anyone familiar with
> >this is going to know what ATAPI_WRITE10 means just fine)
> >
> >Same for request_sense, that is already generalized in cdrom.h as well.
>
> I wonder what FreeBSD is using here? I see no need for invention at
> this place.

The invention would be adding the ATAPI_* commands, Linux has used the
GPCMD_ convention for quite some time now.

--
Jens Axboe

2002-06-20 09:22:23

by Martin Dalecki

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

U?ytkownik Jens Axboe napisa?:
> On Thu, Jun 20 2002, Martin Dalecki wrote:
>
>>U?ytkownik Jens Axboe napisa?:
>>
>>>On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
>>>
>>>Looks pretty good in general, just one minor detail:
>>>
>>>
>>>
>>>>+
>>>>+/*
>>>>+ * ATAPI packet commands.
>>>>+ */
>>>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
>>>>+#define ATAPI_INQUIRY_CMD 0x12
>>>
>>>
>>>[snip]
>>>
>>>We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
>>>that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
>>>variant (and I think the _CMD post fixing is silly, anyone familiar with
>>>this is going to know what ATAPI_WRITE10 means just fine)
>>>
>>>Same for request_sense, that is already generalized in cdrom.h as well.
>>
>>I wonder what FreeBSD is using here? I see no need for invention at
>>this place.
>
>
> The invention would be adding the ATAPI_* commands, Linux has used the
> GPCMD_ convention for quite some time now.

Agreed. The ATAPI prefix would be confusing, since those are in reality SCSI
commands anyway...



Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup


On Thu, 20 Jun 2002, Martin Dalecki wrote:

> U?ytkownik Jens Axboe napisa?:
> > On Thu, Jun 20 2002, Martin Dalecki wrote:
> >
> >>U?ytkownik Jens Axboe napisa?:
> >>
> >>>On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
> >>>
> >>>Looks pretty good in general, just one minor detail:
> >>>
> >>>
> >>>
> >>>>+
> >>>>+/*
> >>>>+ * ATAPI packet commands.
> >>>>+ */
> >>>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
> >>>>+#define ATAPI_INQUIRY_CMD 0x12
> >>>
> >>>
> >>>[snip]
> >>>
> >>>We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
> >>>that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
> >>>variant (and I think the _CMD post fixing is silly, anyone familiar with
> >>>this is going to know what ATAPI_WRITE10 means just fine)
> >>>
> >>>Same for request_sense, that is already generalized in cdrom.h as well.
> >>
> >>I wonder what FreeBSD is using here? I see no need for invention at
> >>this place.
> >
> >
> > The invention would be adding the ATAPI_* commands, Linux has used the
> > GPCMD_ convention for quite some time now.
>
> Agreed. The ATAPI prefix would be confusing, since those are in reality SCSI
> commands anyway...

I think we should use scsi.h and get rid of GPCMD_* convention also.
Jens, do you want "corrected" patch?

--
Bartlomiej Zolnierkiewicz

2002-06-20 16:42:11

by Martin Dalecki

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

U?ytkownik Bartlomiej Zolnierkiewicz napisa?:
> On Thu, 20 Jun 2002, Martin Dalecki wrote:
>
>
>>U?ytkownik Jens Axboe napisa?:
>>
>>>On Thu, Jun 20 2002, Martin Dalecki wrote:
>>>
>>>
>>>>U?ytkownik Jens Axboe napisa?:
>>>>
>>>>
>>>>>On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
>>>>>
>>>>>Looks pretty good in general, just one minor detail:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>+
>>>>>>+/*
>>>>>>+ * ATAPI packet commands.
>>>>>>+ */
>>>>>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
>>>>>>+#define ATAPI_INQUIRY_CMD 0x12
>>>>>
>>>>>
>>>>>[snip]
>>>>>
>>>>>We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
>>>>>that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
>>>>>variant (and I think the _CMD post fixing is silly, anyone familiar with
>>>>>this is going to know what ATAPI_WRITE10 means just fine)
>>>>>
>>>>>Same for request_sense, that is already generalized in cdrom.h as well.
>>>>
>>>>I wonder what FreeBSD is using here? I see no need for invention at
>>>>this place.
>>>
>>>
>>>The invention would be adding the ATAPI_* commands, Linux has used the
>>>GPCMD_ convention for quite some time now.
>>
>>Agreed. The ATAPI prefix would be confusing, since those are in reality SCSI
>>commands anyway...
>
>
> I think we should use scsi.h and get rid of GPCMD_* convention also.
> Jens, do you want "corrected" patch?

Yes that would be best / modulo possible name space clashes.
The names in scsi/scsi.h look too generic sometimes. Like:

#define TYPE_DISK 0x00
#define TYPE_TAPE 0x01
#define TYPE_PRINTER 0x02
#define TYPE_PROCESSOR 0x03 /* HP scanners use this */
#define TYPE_WORM 0x04 /* Treated as ROM by our system */
#define TYPE_ROM 0x05

or

/*
* Status codes
*/

#define GOOD 0x00
#define BUSY 0x04



2002-06-20 16:45:49

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

On Thu, Jun 20 2002, Bartlomiej Zolnierkiewicz wrote:
>
> On Thu, 20 Jun 2002, Martin Dalecki wrote:
>
> > U?ytkownik Jens Axboe napisa?:
> > > On Thu, Jun 20 2002, Martin Dalecki wrote:
> > >
> > >>U?ytkownik Jens Axboe napisa?:
> > >>
> > >>>On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
> > >>>
> > >>>Looks pretty good in general, just one minor detail:
> > >>>
> > >>>
> > >>>
> > >>>>+
> > >>>>+/*
> > >>>>+ * ATAPI packet commands.
> > >>>>+ */
> > >>>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
> > >>>>+#define ATAPI_INQUIRY_CMD 0x12
> > >>>
> > >>>
> > >>>[snip]
> > >>>
> > >>>We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
> > >>>that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
> > >>>variant (and I think the _CMD post fixing is silly, anyone familiar with
> > >>>this is going to know what ATAPI_WRITE10 means just fine)
> > >>>
> > >>>Same for request_sense, that is already generalized in cdrom.h as well.
> > >>
> > >>I wonder what FreeBSD is using here? I see no need for invention at
> > >>this place.
> > >
> > >
> > > The invention would be adding the ATAPI_* commands, Linux has used the
> > > GPCMD_ convention for quite some time now.
> >
> > Agreed. The ATAPI prefix would be confusing, since those are in reality SCSI
> > commands anyway...
>
> I think we should use scsi.h and get rid of GPCMD_* convention also.
> Jens, do you want "corrected" patch?

Note that GPCMD_ is exported to user land, and several programs are
using them for quite some time. So GPCMD_ stays, and that's final.

--
Jens Axboe

Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup


On Thu, 20 Jun 2002, Jens Axboe wrote:

> On Thu, Jun 20 2002, Bartlomiej Zolnierkiewicz wrote:
> >
> > On Thu, 20 Jun 2002, Martin Dalecki wrote:
> >
> > > U?ytkownik Jens Axboe napisa?:
> > > > On Thu, Jun 20 2002, Martin Dalecki wrote:
> > > >
> > > >>U?ytkownik Jens Axboe napisa?:
> > > >>
> > > >>>On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
> > > >>>
> > > >>>Looks pretty good in general, just one minor detail:
> > > >>>
> > > >>>
> > > >>>
> > > >>>>+
> > > >>>>+/*
> > > >>>>+ * ATAPI packet commands.
> > > >>>>+ */
> > > >>>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
> > > >>>>+#define ATAPI_INQUIRY_CMD 0x12
> > > >>>
> > > >>>
> > > >>>[snip]
> > > >>>
> > > >>>We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
> > > >>>that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
> > > >>>variant (and I think the _CMD post fixing is silly, anyone familiar with
> > > >>>this is going to know what ATAPI_WRITE10 means just fine)
> > > >>>
> > > >>>Same for request_sense, that is already generalized in cdrom.h as well.
> > > >>
> > > >>I wonder what FreeBSD is using here? I see no need for invention at
> > > >>this place.
> > > >
> > > >
> > > > The invention would be adding the ATAPI_* commands, Linux has used the
> > > > GPCMD_ convention for quite some time now.
> > >
> > > Agreed. The ATAPI prefix would be confusing, since those are in reality SCSI
> > > commands anyway...
> >
> > I think we should use scsi.h and get rid of GPCMD_* convention also.
> > Jens, do you want "corrected" patch?
>
> Note that GPCMD_ is exported to user land, and several programs are
> using them for quite some time. So GPCMD_ stays, and that's final.
>

There was some discussion that user land should not include linux/ headers
directly, so in long term user land should be fixed not to use GPCMD_* ...



2002-06-20 17:26:33

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 2.5.22] simple ide-tape.c and ide-floppy.c cleanup

On Thu, Jun 20 2002, Bartlomiej Zolnierkiewicz wrote:
>
> On Thu, 20 Jun 2002, Jens Axboe wrote:
>
> > On Thu, Jun 20 2002, Bartlomiej Zolnierkiewicz wrote:
> > >
> > > On Thu, 20 Jun 2002, Martin Dalecki wrote:
> > >
> > > > U?ytkownik Jens Axboe napisa?:
> > > > > On Thu, Jun 20 2002, Martin Dalecki wrote:
> > > > >
> > > > >>U?ytkownik Jens Axboe napisa?:
> > > > >>
> > > > >>>On Wed, Jun 19 2002, Bartlomiej Zolnierkiewicz wrote:
> > > > >>>
> > > > >>>Looks pretty good in general, just one minor detail:
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>>>+
> > > > >>>>+/*
> > > > >>>>+ * ATAPI packet commands.
> > > > >>>>+ */
> > > > >>>>+#define ATAPI_FORMAT_UNIT_CMD 0x04
> > > > >>>>+#define ATAPI_INQUIRY_CMD 0x12
> > > > >>>
> > > > >>>
> > > > >>>[snip]
> > > > >>>
> > > > >>>We already have the "full" list in cdrom.h (GPCMD_*), so lets just use
> > > > >>>that. After all, ATAPI_MODE_SELECT10_CMD _is_ the same as the SCSI
> > > > >>>variant (and I think the _CMD post fixing is silly, anyone familiar with
> > > > >>>this is going to know what ATAPI_WRITE10 means just fine)
> > > > >>>
> > > > >>>Same for request_sense, that is already generalized in cdrom.h as well.
> > > > >>
> > > > >>I wonder what FreeBSD is using here? I see no need for invention at
> > > > >>this place.
> > > > >
> > > > >
> > > > > The invention would be adding the ATAPI_* commands, Linux has used the
> > > > > GPCMD_ convention for quite some time now.
> > > >
> > > > Agreed. The ATAPI prefix would be confusing, since those are in reality SCSI
> > > > commands anyway...
> > >
> > > I think we should use scsi.h and get rid of GPCMD_* convention also.
> > > Jens, do you want "corrected" patch?
> >
> > Note that GPCMD_ is exported to user land, and several programs are
> > using them for quite some time. So GPCMD_ stays, and that's final.
> >
>
> There was some discussion that user land should not include linux/ headers
> directly, so in long term user land should be fixed not to use GPCMD_* ...

Irrelevant, these are propagated to user land through glibc anyways.
Look, it's a convenience. These have existed since 2.2.x + dvd patches,
and they are not going away just because you want to make up some new
names.

--
Jens Axboe

Subject: [redone PATCH 2.5.22] simple ide-tape/floppy.c cleanup


redone without controversial bits...

generic ATAPI hit #1 against 2.5.22:

- move generic ATAPI structs from ide/ide-floppy.c
and ide/ide-tape.c to include/atapi.h
(this has a nice side effect of making ide-tape
a bit more endianness aware)

- remove IDEFLOPPY_MIN/MAX() macros, use generic ones

- add #ifndef __LINUX_ATAPI_H_ blabla to atapi.h
to prevent including it more than once


should apply cleanly to 2.5.23
--
Bartlomiej Zolnierkiewicz


Attachments:
atapi-1a.diff (32.84 kB)

2002-06-24 18:00:36

by Martin Dalecki

[permalink] [raw]
Subject: Re: [redone PATCH 2.5.22] simple ide-tape/floppy.c cleanup

U?ytkownik Bartlomiej Zolnierkiewicz napisa?:
> redone without controversial bits...
>
> generic ATAPI hit #1 against 2.5.22:
>
> - move generic ATAPI structs from ide/ide-floppy.c
> and ide/ide-tape.c to include/atapi.h
> (this has a nice side effect of making ide-tape
> a bit more endianness aware)
>
> - remove IDEFLOPPY_MIN/MAX() macros, use generic ones
>
> - add #ifndef __LINUX_ATAPI_H_ blabla to atapi.h
> to prevent including it more than once
>
>
> should apply cleanly to 2.5.23


Hi Bartek. Nice to see that you picked up on the idea
of code duplication reduction. I think the solution to
the packet comand declarations problesm will be to
move them over from cdrom.h to linux/scsi.h and just letting
scsi/scsi.h include linux/scsi.h. This should even make
distros still linking to kernle headers from /usr/include
happy and will achieve the goal of unification.

And I agree with Jens that for pragmatic reasons we should
just keep the prefix from cdrom.h - it's there and doesn't hurt
but we need one, so why not stick with it? The plain macros
from scsi.h are too ambigous anyway.