Commit f1b60d46b6f1274f1eacfc89ddbf7f6b63348196
Committed by
Linus Torvalds
1 parent
a4be29ac6d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
drivers/video/backlight/ot200_bl.c: use devm_ functions
The devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_kzalloc of these functions Signed-off-by: Jingoo Han <jg1.han@samsung.com> Cc: Christian Gmeiner <christian.gmeiner@gmail.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 4 additions and 8 deletions Side-by-side Diff
drivers/video/backlight/ot200_bl.c
... | ... | @@ -97,10 +97,10 @@ |
97 | 97 | goto error_mfgpt_alloc; |
98 | 98 | } |
99 | 99 | |
100 | - data = kzalloc(sizeof(*data), GFP_KERNEL); | |
100 | + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | |
101 | 101 | if (!data) { |
102 | 102 | retval = -ENOMEM; |
103 | - goto error_kzalloc; | |
103 | + goto error_devm_kzalloc; | |
104 | 104 | } |
105 | 105 | |
106 | 106 | /* setup gpio */ |
107 | 107 | |
... | ... | @@ -122,16 +122,14 @@ |
122 | 122 | if (IS_ERR(bl)) { |
123 | 123 | dev_err(&pdev->dev, "failed to register backlight\n"); |
124 | 124 | retval = PTR_ERR(bl); |
125 | - goto error_backlight_device_register; | |
125 | + goto error_devm_kzalloc; | |
126 | 126 | } |
127 | 127 | |
128 | 128 | platform_set_drvdata(pdev, bl); |
129 | 129 | |
130 | 130 | return 0; |
131 | 131 | |
132 | -error_backlight_device_register: | |
133 | - kfree(data); | |
134 | -error_kzalloc: | |
132 | +error_devm_kzalloc: | |
135 | 133 | cs5535_mfgpt_free_timer(pwm_timer); |
136 | 134 | error_mfgpt_alloc: |
137 | 135 | gpio_free(GPIO_DIMM); |
... | ... | @@ -141,7 +139,6 @@ |
141 | 139 | static int ot200_backlight_remove(struct platform_device *pdev) |
142 | 140 | { |
143 | 141 | struct backlight_device *bl = platform_get_drvdata(pdev); |
144 | - struct ot200_backlight_data *data = bl_get_data(bl); | |
145 | 142 | |
146 | 143 | backlight_device_unregister(bl); |
147 | 144 | |
... | ... | @@ -154,7 +151,6 @@ |
154 | 151 | cs5535_mfgpt_free_timer(pwm_timer); |
155 | 152 | gpio_free(GPIO_DIMM); |
156 | 153 | |
157 | - kfree(data); | |
158 | 154 | return 0; |
159 | 155 | } |
160 | 156 |