linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@baker-net.org.uk (Adam Baker)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/3] hwmon: Create an NSA320 hardware monitoring driver
Date: Wed, 2 Mar 2016 23:43:32 +0000	[thread overview]
Message-ID: <56D77AA4.2080908@baker-net.org.uk> (raw)
In-Reply-To: <56D3948D.6000805@roeck-us.net>

On 29/02/16 00:45, Guenter Roeck wrote:

>> +
>> +/*
>> + * Although this protocol looks similar to SPI the long delay
>> + * between the active (aka chip select) signal and the shorter
>> + * delay between clock pulses are needed for reliable operation.
>> + * The delays provided are taken from the manufacturer kernel,
>> + * testing suggest they probably incorporate a reasonable safety
>> + * margin. (The single device tested became unreliable if the
>> + * delay was reduced to 1/10th of this value.)
>> + */
>> +static unsigned long nsa320_hwmon_update(struct device *dev)
>
> Please make this either int or s32.
>
>> +{
>> +    u32 mcu_data;
>
> You can (and should) still use u32 here.
>


I'm a bit puzzled by your reasoning for preferring a signed value for 
the return value. The only reason I can think of is that the error 
return value is negative, however the macro to test if it is an error 
value is not looking at whether the value is negative

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

Functionally using any of s32, int or unsigned long will make no 
difference, the mask operations ensure that the top bit can't possibly 
be set so using a signed type doesn't, in this circumstance, risk an 
undefined result from the shift operation. The choice of type is 
therefore a matter of readability rather than function so if you still 
prefer s32 I'll respin it to use that.

The length does need to be at least 32 bits (to represent the returned 
data range) and no longer than unsigned long (to avoid breaking 
IS_ERR_VALUE). Whilst int is 32 bits on the only processor that is 
expected to use this device that doesn't feel like a good thing to 
depend upon so s32 seems preferable to int.

Regards

Adam

  reply	other threads:[~2016-03-02 23:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-28 22:30 [PATCH v3 0/3] driver for the hardware monitoring chip in the Zyxel NSA320 Adam Baker
2016-02-28 22:30 ` [PATCH v3 1/3] hwmon: Define binding for the nsa320-hwmon driver Adam Baker
2016-02-28 22:30 ` [PATCH v3 2/3] hwmon: Create an NSA320 hardware monitoring driver Adam Baker
2016-02-29  0:45   ` Guenter Roeck
2016-03-02 23:43     ` Adam Baker [this message]
2016-03-03  4:38       ` Guenter Roeck
2016-02-28 22:30 ` [PATCH v3 3/3] ARM: mvebu: Add the hardware monitor to the NSA320 device tree Adam Baker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56D77AA4.2080908@baker-net.org.uk \
    --to=linux@baker-net.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).