Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1198405
| From | Jonathan Cameron <jic23@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/2] iio: magnetometer: add mmc34160 magnetometer driver |
| Date | 2015-08-02 18:40 +0200 |
| Message-ID | <pT4sN-148-15@gated-at.bofh.it> (permalink) |
| References | <pOjLQ-30h-3@gated-at.bofh.it> <pOjLQ-30h-21@gated-at.bofh.it> <pOk5b-3CG-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 20/07/15 15:14, Dan Carpenter wrote:
> On Mon, Jul 20, 2015 at 04:52:30PM +0300, Teodora Baluta wrote:
>> +static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
>> + int index, int *val)
>> +{
>> + switch (index) {
>> + case AXIS_X:
>> + *val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X];
>> + break;
>> + case AXIS_Y:
>> + *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y];
>> + break;
>> + case AXIS_Z:
>> + *val = (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
>> + break;
>> + default:
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>
> We never pass invalid indexes here so this could be replaced with:
>
> static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
> int index, int *val)
> {
> *val = (raw[index] - nfo) * 1000 / sens[index];
> return 0;
Even better change the function signature and don't return anything at
all perhaps?
Anyhow, definitely worth making this change.
> }
>
> regards,
> dan carpenter
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
Re: [PATCH v2 2/2] iio: magnetometer: add mmc34160 magnetometer driver Jonathan Cameron <jic23@kernel.org> - 2015-08-02 18:40 +0200 Re: [PATCH v2 2/2] iio: magnetometer: add mmc34160 magnetometer driver Dan Carpenter <dan.carpenter@oracle.com> - 2015-08-02 18:40 +0200
csiph-web