From: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, len.brown@intel.com,
don@syst.com.br, linux-acpi@vger.kernel.org,
cascardo@holoscopio.com
Subject: Re: [PATCH] cmpc_acpi: Added support for Classmate PC ACPI devices.
Date: Tue, 29 Sep 2009 13:05:22 -0700 [thread overview]
Message-ID: <20090929130522.ecf4d5ec.akpm@linux-foundation.org> (raw)
In-Reply-To: <1254188280-29155-1-git-send-email-cascardo@holoscopio.com>
On Mon, 28 Sep 2009 22:38:00 -0300
Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> wrote:
> This add supports for devices like keyboard, backlight, tablet and
> accelerometer.
>
> This work is supported by International Syst S/A.
>
I need to have a big whine about the coding style.
> +static acpi_status cmpc_start_accel(acpi_handle handle)
> +{
> + union acpi_object param[2];
> + struct acpi_object_list input;
> + acpi_status status;
> + param[0].type = ACPI_TYPE_INTEGER;
> + param[0].integer.value = 0x3;
> + param[1].type = ACPI_TYPE_INTEGER;
> + input.count = 2;
> + input.pointer = param;
> + status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
> + return status;
> +}
To the jaded kernel developer's eye, this is quite hard to read. Every
function here squishes the declarations of the locals up against the
start of the code. It's a small thing, but this:
static acpi_status cmpc_start_accel(acpi_handle handle)
{
union acpi_object param[2];
struct acpi_object_list input;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x3;
param[1].type = ACPI_TYPE_INTEGER;
input.count = 2;
input.pointer = param;
status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
return status;
}
puts a smile on our faces.
>
> ...
>
> +static ssize_t cmpc_accel_sense_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct acpi_device *acpi;
> + int sense;
> + acpi = to_acpi_device(dev);
> + if (sscanf(buf, "%d", &sense) <= 0)
> + return -EINVAL;
> + cmpc_accel_set_sense(acpi->handle, sense);
> + return strnlen(buf, count);
> +}
This will treat input of the form "42foo" as a valid decimal number.
That's a bit sloppy. Can we use strict_strtoul() here?
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: linux-kernel@vger.kernel.org, len.brown@intel.com,
don@syst.com.br, linux-acpi@vger.kernel.org,
cascardo@holoscopio.com
Subject: Re: [PATCH] cmpc_acpi: Added support for Classmate PC ACPI devices.
Date: Tue, 29 Sep 2009 13:05:22 -0700 [thread overview]
Message-ID: <20090929130522.ecf4d5ec.akpm@linux-foundation.org> (raw)
In-Reply-To: <1254188280-29155-1-git-send-email-cascardo@holoscopio.com>
On Mon, 28 Sep 2009 22:38:00 -0300
Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> wrote:
> This add supports for devices like keyboard, backlight, tablet and
> accelerometer.
>
> This work is supported by International Syst S/A.
>
I need to have a big whine about the coding style.
> +static acpi_status cmpc_start_accel(acpi_handle handle)
> +{
> + union acpi_object param[2];
> + struct acpi_object_list input;
> + acpi_status status;
> + param[0].type = ACPI_TYPE_INTEGER;
> + param[0].integer.value = 0x3;
> + param[1].type = ACPI_TYPE_INTEGER;
> + input.count = 2;
> + input.pointer = param;
> + status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
> + return status;
> +}
To the jaded kernel developer's eye, this is quite hard to read. Every
function here squishes the declarations of the locals up against the
start of the code. It's a small thing, but this:
static acpi_status cmpc_start_accel(acpi_handle handle)
{
union acpi_object param[2];
struct acpi_object_list input;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x3;
param[1].type = ACPI_TYPE_INTEGER;
input.count = 2;
input.pointer = param;
status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
return status;
}
puts a smile on our faces.
>
> ...
>
> +static ssize_t cmpc_accel_sense_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct acpi_device *acpi;
> + int sense;
> + acpi = to_acpi_device(dev);
> + if (sscanf(buf, "%d", &sense) <= 0)
> + return -EINVAL;
> + cmpc_accel_set_sense(acpi->handle, sense);
> + return strnlen(buf, count);
> +}
This will treat input of the form "42foo" as a valid decimal number.
That's a bit sloppy. Can we use strict_strtoul() here?
next prev parent reply other threads:[~2009-09-29 20:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-29 1:38 [PATCH] cmpc_acpi: Added support for Classmate PC ACPI devices Thadeu Lima de Souza Cascardo
2009-09-29 9:20 ` Alan Jenkins
2009-09-29 14:16 ` Thadeu Lima de Souza Cascardo
2009-09-29 16:41 ` Alan Jenkins
2009-10-01 16:38 ` Dmitry Torokhov
2009-09-29 16:12 ` Bjorn Helgaas
2009-09-29 20:05 ` Andrew Morton [this message]
2009-09-29 20:05 ` Andrew Morton
2009-09-29 20:10 ` Thadeu Lima de Souza Cascardo
2009-09-29 20:17 ` Joe Perches
2009-09-30 15:50 ` Bjorn Helgaas
2009-09-30 17:51 ` Thadeu Lima de Souza Cascardo
2009-09-30 18:27 ` Bjorn Helgaas
2009-09-30 18:57 ` Thadeu Lima de Souza Cascardo
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=20090929130522.ecf4d5ec.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cascardo@holoscopio.com \
--cc=don@syst.com.br \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.