From: Johan Hedberg <johan.hedberg@gmail.com>
To: Urja Rannikko <urjaman@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] hciattach_tialt: Implement texas_change_speed function.
Date: Fri, 30 Mar 2012 13:37:09 +0300 [thread overview]
Message-ID: <20120330103709.GA12656@x220> (raw)
In-Reply-To: <CAPCnQJnPC3Abgg7r_HL_27V-0DZ8EZ7ufopySFiZ4nL1wREzYw@mail.gmail.com>
Hi Urja,
On Thu, Mar 29, 2012, Urja Rannikko wrote:
> I'm working on bluetooth on the pandora handheld console, and this
> functionality was missing.
> This is my first mail on this list, and I'm not 100% sure on all the
> customs here, but I think this is sufficient:
If possible please use git send-email instead of sending patches as
attachments.
> Signed-off-by: Urja Rannikko <urjaman@gmail.com>
This convention is only used for kernel-side patches.
> +static int poll_wait_reply(int fd, int ms) {
The { goes on its own line.
> + struct pollfd pfd;
> + pfd.fd = fd;
Empty line after the initial variable declarations.
> + pfd.events = POLLIN;
> + pfd.revents = 0;
> + return poll(&pfd, 1, ms);
> +}
Empty line before return. ...
> +static int texas_change_speed(int fd, uint32_t speed) {
Same thing here with the {
> + int i;
> + texas_speed_change_cmd_t cmd;
> + fprintf(stdout,"Sending speed change command..\n");
And again empty line after the variable declarations. Also missing space
after the comma (I'd have requested you to use printf instead of fprintf
since you're using stdout but I noticed that the rest of the file does
this too; feel free to send a separate cleanup patch for that if you
wish though).
> + for (i=0;i<3;i++) {
This should be:
for (i = 0; i < 3; i++) {
> + int n = write(fd,&cmd,sizeof(cmd));
The return value of write is ssize_t and not int (not that it makes much
difference but it doesn't hurt to be consistent here). Also, missing
space after each comma.
> + if (n < 0) {
> + perror("Failed to write speed change command");
> + return -1;
> + }
> + if (n < sizeof(cmd)) {
Add an empty line before the second if
> + fprintf(stderr, "Wanted to write %lu bytes, could only write %d. Stop\n", sizeof(cmd), n);
Keep your lines under 80 characters please.
> + return -1;
> + }
> + if (poll_wait_reply(fd,100)!=1) continue;
Empty line before the if and put the continue on its own line. Also,
missing space before and after !=
> + return read_command_complete(fd,cmd.hci_hdr.opcode,cmd.hci_hdr.plen);
Missing spaces after each comma.
> + }
> + fprintf(stderr,"Speed change command timeout.\n");
Add an empty line before the fprintf. Also, missing space after the
comma.
> + if (texas_change_speed(fd, speed)) return -1;
Put the return statement on its own line.
Johan
prev parent reply other threads:[~2012-03-30 10:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 17:17 [PATCH] hciattach_tialt: Implement texas_change_speed function Urja Rannikko
2012-03-30 10:37 ` Johan Hedberg [this message]
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=20120330103709.GA12656@x220 \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=urjaman@gmail.com \
/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.