Re: amateur query in Uniform cdrom device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/31/05, Raseel Bhagat <rabhagat@xxxxxxxxxx> wrote:
> 
> Hi,
>   I'm very newbie trying to browse the kernel source and especially the
> device driver code written in it.
> Currently I'm loking at the Uniform Cdrom Driver in
> .../linux/drivers/cdrom/cdrom.c
> I'm a bit confused about the _SIGNIFICANCE_ AND _USABILITY_ of the macro
> :ENSURE .

Did you try reading the comments before said macro?

"/* This macro makes sure we don't have to check on cdrom_device_ops
 * existence in the run-time routines below. Change_capability is a
 * hack to have the capability flags defined const, while we can still
 * change it here without gcc complaining at every line.
 */"

And for reference, here's the #define:

#define ENSURE(call, bits) if (cdo->call == NULL) *change_capability &= ~(bits)

1) It's a hack, but it works.
2) Basically, all it does is see if the function is defined for a
particular cdrom_device_ops struct. If it isn't (i.e., the member is
NULL), then we remove those capability bits.

This a particularly nasty macro, as it assumes something called cdo
exists and something called change_capability exists. But it's only
used in the register function and then immediately #undef'd.

In any case, I just explained the code. What are you actually trying
to find out?
Thanks,
Nish

P.S. Please always state which kernel you are looking at when
referring to any given file -- things in Linux change quite often :)

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux