[PATCH 1/2] serial_ns16550: move switch from ns16550_{read, write}() to ns16550_probe()
Antony Pavlov
antonynpavlov at gmail.com
Thu Aug 4 03:30:21 EDT 2011
On 4 August 2011 04:42, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj at jcrosoft.com> wrote:
> On 22:37 Wed 03 Aug , Antony Pavlov wrote:
>> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
>> ---
>> drivers/serial/serial_ns16550.c | 87 ++++++++++++++++++++++++---------------
>> 1 files changed, 54 insertions(+), 33 deletions(-)
>>
>> + plat->reg_write(val, (unsigned long)dev->priv, off);
> no it must stay void __iomem*
plat->reg_write() get the second argument 'unsigned long base'.
Moreover, using 'void *' in arithmetic is a poor practice.
Fortunally for us, in GCC incrementing a void pointer adds one to the
value (sizeof(void) == 1).
Add '-pedantic' flag to gcc and compile current 'next' barebox.
You will see something like this:
In function ‘ns16550_read’:
drivers/serial/serial_ns16550.c:72: warning: pointer of type ‘void *’
used in arithmetic
>> + if (plat->reg_read == NULL) {
>> + int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
>> +
>> + switch (width) {
>> + default:
...
>> + }
>> + }
>> +
>> + if (plat->reg_write == NULL) {
>> + int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> why do it twice?
You are right.
width calculation or even separate reg_write & reg_read handling can
be combined.
--
Best regards,
Antony Pavlov
More information about the barebox
mailing list