Re: 2.1.10 FYI

Erik B. Andersen (
Fri, 15 Nov 1996 16:56:20 -0700 (MST)

>From the latest version of Documentation/cdrom/cdrom-standard.tex:

... These parameters are declared $const$ because they describe properties
of the drive, which don't change after registration. ... The
capability flag is declared $const$, to prevent drivers from
accidentally tampering with the contents.

The patch you submitted for ucdrom.h is the WrongThing(tm). These values
must be set during drive registration, but they should be declared const so
that nothing can change them subsequently (thereby screwing up the kernel).

I suggest that include/linux/ucdrom.h should NOT be changed. This
very issue was discussed some time ago between David van Leeuwen (the
creator of the generic cdrom interface) and Scott Snyder (the previous
ide-cd maintainer). I can send you a (partail) archive of their discussion
if you wish.

The ide-cd driver simply adds a cast to suppress the compiler warning.
This allows you to set the const values on drive initialization without
warnings. Just don't do this somewhere else in your code... This is the
RightThing(tm) to do, IMHO. Do something like this to sr.c:

static int ide_cdrom_register (ide_drive_t *drive, int nslots)
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo;
int minor = (drive->select.b.unit)<<PARTN_BITS;

devinfo->dev = MKDEV (HWIF(drive)->major, minor);
devinfo->ops = &ide_cdrom_dops;
devinfo->mask = 0;
---> *(int *)&devinfo->speed = 0;
---> *(int *)&devinfo->capacity = nslots;
devinfo->handle = (void *) drive;

return register_cdrom (devinfo, drive->name);


Erik B. Andersen        Web: 
2485 South State St.    email: or
Springville, Ut 84663   phone:  (801) 489-1231
--This message was written using 73% post-consumer electrons--

Gerd Knorr wrote: > > > In you write: > > >sr.c: In function `sr_attach': > >sr.c:796: warning: assignment of read-only member `speed' > >sr.c:797: warning: assignment of read-only member `capacity' > > Yes, these are declared const in ucdrom.h, but they shoult'nt. These > values depend on the drive you have, so you have to write in there > something after checking drives capabilities. > > Gerd

[**** patch which I believe should NOT go into the kernel snipped ****]