diff options
author | Joe Perches <joe@perches.com> | 2010-12-09 22:29:07 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-12-10 09:13:43 -0500 |
commit | a3789a1783d37f2772ba5046b26416c98dfe1bfa (patch) | |
tree | 3ac0370ff39d36ff3ac9b74ba26f425e7c2f393b /drivers/hid/hid-core.c | |
parent | 16ee4cc82b5dbb81a5dbfedcdb268b9467fe4605 (diff) |
HID: Hoist assigns from ifs
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r-- | drivers/hid/hid-core.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index e6b90622e4eb..86b7155632fb 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -61,7 +61,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type, | |||
61 | if (report_enum->report_id_hash[id]) | 61 | if (report_enum->report_id_hash[id]) |
62 | return report_enum->report_id_hash[id]; | 62 | return report_enum->report_id_hash[id]; |
63 | 63 | ||
64 | if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) | 64 | report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); |
65 | if (!report) | ||
65 | return NULL; | 66 | return NULL; |
66 | 67 | ||
67 | if (id != 0) | 68 | if (id != 0) |
@@ -92,8 +93,11 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned | |||
92 | return NULL; | 93 | return NULL; |
93 | } | 94 | } |
94 | 95 | ||
95 | if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) | 96 | field = kzalloc((sizeof(struct hid_field) + |
96 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; | 97 | usages * sizeof(struct hid_usage) + |
98 | values * sizeof(unsigned)), GFP_KERNEL); | ||
99 | if (!field) | ||
100 | return NULL; | ||
97 | 101 | ||
98 | field->index = report->maxfield++; | 102 | field->index = report->maxfield++; |
99 | report->field[field->index] = field; | 103 | report->field[field->index] = field; |
@@ -211,7 +215,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign | |||
211 | unsigned offset; | 215 | unsigned offset; |
212 | int i; | 216 | int i; |
213 | 217 | ||
214 | if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { | 218 | report = hid_register_report(parser->device, report_type, parser->global.report_id); |
219 | if (!report) { | ||
215 | dbg_hid("hid_register_report failed\n"); | 220 | dbg_hid("hid_register_report failed\n"); |
216 | return -1; | 221 | return -1; |
217 | } | 222 | } |
@@ -229,7 +234,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign | |||
229 | 234 | ||
230 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); | 235 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
231 | 236 | ||
232 | if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL) | 237 | field = hid_register_field(report, usages, parser->global.report_count); |
238 | if (!field) | ||
233 | return 0; | 239 | return 0; |
234 | 240 | ||
235 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); | 241 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); |
@@ -891,7 +897,8 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, | |||
891 | __s32 max = field->logical_maximum; | 897 | __s32 max = field->logical_maximum; |
892 | __s32 *value; | 898 | __s32 *value; |
893 | 899 | ||
894 | if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC))) | 900 | value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); |
901 | if (!value) | ||
895 | return; | 902 | return; |
896 | 903 | ||
897 | for (n = 0; n < count; n++) { | 904 | for (n = 0; n < count; n++) { |