Skip to contentSkip to conversation

Add Dell laptop driver

PATCH Parag Warudkar 2 participants 3 messages Aug 16, 2008

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Matthew Garrett <mjg59 <at> srcf.ucam.org> writes:
drivers/misc/dell-laptop.c new file +0 -0
new file mode 100644
index 0000000..ab09a69

[Snip]

drivers/misc/dell-laptop.c

Quoted 6 lines
drivers/misc/dell-laptop.c new file +6 -0
+	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?

drivers/misc/dell-laptop.c

Quoted 9 lines
drivers/misc/dell-laptop.c new file +8 -0
+
+	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.

drivers/misc/dell-laptop.c

Quoted 12 lines
drivers/misc/dell-laptop.c new file +11 -0
+	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.

drivers/misc/dell-laptop.c

Quoted 11 lines
drivers/misc/dell-laptop.c new file +10 -0
+	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 :)

Quoted 9 lines
drivers/misc/dell-laptop.c new file +9 -0
+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);
+}

drivers/misc/dell-laptop.c

Quoted 10 lines
drivers/misc/dell-laptop.c new file +10 -0
+
+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.

drivers/misc/dell-laptop.c

Quoted 6 lines
drivers/misc/dell-laptop.c new file +6 -0
+
+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!

Quoted 5 lines
drivers/misc/dell-laptop.c new file +5 -0
+
+	buffer->input[0] = find_token_location(0x7d);
+	buffer->input[1] = intensity;
+
+	if (buffer->input[0] == -1) {

drivers/misc/dell-laptop.c

Quoted 10 lines
drivers/misc/dell-laptop.c new file +8 -0
+		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++;

drivers/misc/dell-laptop.c

Quoted 9 lines
drivers/misc/dell-laptop.c new file +9 -0
+	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.

drivers/misc/dell-laptop.c

Quoted 7 lines
drivers/misc/dell-laptop.c new file +7 -0
+	buffer->input[0] = find_token_location(0x7d);
+
+	if (buffer->input[0] != -1) {
+		dell_send_request(buffer, 2, 1);
+		max_intensity = buffer->output[3];
+	}
+

Parag

#1 lore raw
Quoted 5 lines · Parag Warudkar

Review

Quoted 3 lines
(quoted diff) +3 -0
+	da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
+			     sizeof(struct calling_interface_token),
+			     GFP_KERNEL);

Isn't a NULL check required here?

To the extent that it would result in this failing gracefully before some other part of the kernel becomes hideously upset, sure. I have a hard time caring, but I can easily fix it if other people do :)

Signature · 1 line
Matthew Garrett | [email protected]
#2 lore raw
Quoted 10 lines · Matthew Garrett
Quoted 5 lines · Parag Warudkar

Review

Quoted 3 lines
(quoted diff) +3 -0
+   da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
+                        sizeof(struct calling_interface_token),
+                        GFP_KERNEL);

Isn't a NULL check required here?

To the extent that it would result in this failing gracefully before some other part of the kernel becomes hideously upset, sure. I have a hard time caring, but I can easily fix it if other people do :)

Yeah, it's a RFKill switch after all, not a LaptopKill switch :)

Seriously though a quick search through LXR results for kzalloc shows that most everyone does care.
And if I find ones that don't a patch will follow soon.

Thanks

Parag