driver coding style

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

 



Hi there,

To access device registers, which one is best practice in terms of
coding style, and is any of them totally unacceptable for a driver to
be merged to the kernel?

1) Is this ok?
static inline unsigned int device_read_reg(int offset)
{
	return readl(device_global_struct->base + offset);
}

static inline void device_write_reg(int offset, unsigned int data)
{
	writel(device_global_struct->base + offset, data);
	return;
}

2) I've seen this in some kernel code, note the &:
readl(&device_global_struct->registeroffset);
writel(&device_global_struct->registeroffset, data);

3) Also possible:
readl(device_global_struct->registeroffset);
writel(device_global_struct->registeroffset, data);

Any comments?

Thanks,
Bahadir

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