Re: amateur query in Uniform cdrom device driver

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

 




Nish Aravamudan wrote:

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)
Hi ,
I did read the comment, but I was confused because the 'change_capability' variable is not reassigned to 'cdo->capability'.
What I mean is , once ENSURE is executed, shouldn't the next step be
 cdo->capabilty = *change_capability;
And anyways, the CDROM_CAN macro is used for masking the cdo->capability everywhere else in the code.

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.
Yeah, I got this part. But to remove the "capability", the cdo->capability needs to be masked which is done by CDROM_CAN macro. Hence, I was wondering if there was any other specific significance of ENSURE macro.

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

P.S. Please always state which kernel you are looking at when
referring to any given file -- things in Linux change quite often :)
I'm sorry. It was extremely negligent on my part to not have mentioned the Kernel.
I am working on the olf 2.4.20 kernel.


--
Thanking You,
Raseel Bhagat
Software Engineer
Nortel-BU BSC-PST (Simulators)
Sasken Communications Technologies Ltd.
139/25,Ring Road,Domlur
Bangalore - 560 071
Phone : + 91 80 25355501 Extn: 3388
Email : rabhagat@xxxxxxxxxx
URL : http://www.sasken.com


"SASKEN RATED THE BEST EMPLOYER IN THE COUNTRY by the BUSINESS TODAY Mercer Survey 2004"


                          SASKEN BUSINESS DISCLAIMER
This message may contain confidential, proprietary or legally Privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, Disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender. Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Sasken Communication Technologies Limited ("Sasken") unless sent with that express intent and with due authority of Sasken. Sasken has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email

--
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