mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Parag Warudkar" <parag.warudkar@gmail.com>
To: mjg59@srcf.ucam.org
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] Add Dell laptop driver
Date: Sat, 16 Aug 2008 19:17:05 -0400	[thread overview]
Message-ID: <82e4877d0808161617k5404f4ectf6d502de5b7fea4c@mail.gmail.com> (raw)

Matthew Garrett <mjg59 <at> srcf.ucam.org> writes:



> diff --git a/drivers/misc/dell-laptop.c b/drivers/misc/dell-laptop.c
> new file mode 100644
> index 0000000..ab09a69
> --- /dev/null
> +++ b/drivers/misc/dell-laptop.c

[Snip]

> +	da_command_address = table->cmdIOAddress;
> +	da_command_code = table->cmdIOCode;
> +
> +	da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
> +			     sizeof(struct calling_interface_token),
> +			     GFP_KERNEL);

Isn't a NULL check required here?

> +
> +	memcpy(da_tokens+da_num_tokens, table->tokens,
> +	       sizeof(struct calling_interface_token) * tokens);
> +

> +static struct calling_interface_buffer *dell_send_request(
> +	struct calling_interface_buffer *buffer, int class, int select)
> +{
> +	struct smi_cmd *command = kzalloc(sizeof(struct smi_cmd), GFP_KERNEL);

NULL check - Here too.

> +	command->magic = SMI_CMD_MAGIC;
> +	command->command_address = da_command_address;
> +	command->command_code = da_command_code;
> +	command->ebx = virt_to_phys(buffer);
> +	command->ecx = 0x42534931;
> +

> +
> +static int dell_rfkill_set(int radio, enum rfkill_state state)
> +{
> +	struct calling_interface_buffer *buffer =
> +		kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);

Ditto.

> +	int disable = (state == RFKILL_STATE_UNBLOCKED) ? 0 : 1;
> +	buffer->input[0] = (1 | (radio<<8) | (disable << 16));
> +	dell_send_request(buffer, 17, 11);
> +	kfree(buffer);
> +	return 0;
> +}

> +static int dell_rfkill_get(int bit, enum rfkill_state *state)
> +{
> +	struct calling_interface_buffer *buffer =
> +		kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);

This makes me confident there is code in the kernel that always
succeeds allocations by mjg59.
Just got to find where it's hidden :)


> +static int dell_wifi_get(void *data, enum rfkill_state *state)
> +{
> +	return dell_rfkill_get(17, state);
> +}
> +
> +static int dell_bluetooth_get(void *data, enum rfkill_state *state)
> +{
> +	return dell_rfkill_get(18, state);
> +}
> +
> +static int dell_wwan_get(void *data, enum rfkill_state *state)
> +{
> +	return dell_rfkill_get(19, state);
> +}
> +
> +static void dell_setup_rfkill(void)
> +{
> +	struct calling_interface_buffer *buffer =
> +		kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);

Once more.

> +
> +static int dell_send_intensity(struct backlight_device *bd)
> +{
> +	int intensity = bd->props.brightness;
> +	struct calling_interface_buffer *buffer =
> +		kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);

Stopped counting!

> +
> +	buffer->input[0] = find_token_location(0x7d);
> +	buffer->input[1] = intensity;
> +
> +	if (buffer->input[0] == -1) {
> +		kfree(buffer);
> +		return -ENODEV;
> +	}


> +
> +static int dell_get_intensity(struct backlight_device *bd)
> +{
> +	struct calling_interface_buffer *buffer =
> +		kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);

count_prev++;

> +	if (!dmi_check_system(dell_device_table))
> +		return -ENODEV;
> +
> +	dmi_walk(find_tokens);
> +
> +	if (!da_tokens)
> +		return -ENODEV;
> +
> +	buffer = kzalloc(sizeof(struct calling_interface_buffer), GFP_KERNEL);

One last.

> +	buffer->input[0] = find_token_location(0x7d);
> +
> +	if (buffer->input[0] != -1) {
> +		dell_send_request(buffer, 2, 1);
> +		max_intensity = buffer->output[3];
> +	}
> +


Parag

             reply	other threads:[~2008-08-16 23:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-16 23:17 Parag Warudkar [this message]
2008-08-16 23:23 ` Matthew Garrett
2008-08-16 23:31   ` Parag Warudkar
  -- strict thread matches above, loose matches on Subject: below --
2008-08-16 20:24 [PATCH 0/2] " Matthew Garrett
2008-08-16 20:26 ` [PATCH 1/2] Export SMI call functionality from dcdbas driver Matthew Garrett
2008-08-16 20:30   ` [PATCH 2/2] Add Dell laptop driver Matthew Garrett
2008-08-16 20:47     ` Arjan van de Ven
2008-08-16 20:51       ` Matthew Garrett
2008-08-20  6:46     ` Andrew Morton
2008-08-20 10:21       ` Matthew Garrett

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=82e4877d0808161617k5404f4ectf6d502de5b7fea4c@mail.gmail.com \
    --to=parag.warudkar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.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

Powered by JetHome