aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps
diff options
context:
space:
mode:
authorJan Luebbe <jlu@pengutronix.de>2013-07-03 18:09:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:08:06 -0400
commit2a65182235790fc9a6abb9f41c1006c95f506545 (patch)
treeb6b6bd37a312605a3fe6ef00eb5b7e02094d1f65 /drivers/pps
parentc32df4e182e5bf40edde45da247318986d3cbf91 (diff)
drivers/pps/clients/pps-gpio.c: convert to devm_* helpers
Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps')
-rw-r--r--drivers/pps/clients/pps-gpio.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index d3db26e46489..54c2809021a3 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev)
74 int ret; 74 int ret;
75 const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data; 75 const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
76 76
77 ret = gpio_request(pdata->gpio_pin, pdata->gpio_label); 77 ret = devm_gpio_request(&pdev->dev, pdata->gpio_pin, pdata->gpio_label);
78 if (ret) { 78 if (ret) {
79 pr_warning("failed to request GPIO %u\n", pdata->gpio_pin); 79 pr_warning("failed to request GPIO %u\n", pdata->gpio_pin);
80 return -EINVAL; 80 return -EINVAL;
@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev)
83 ret = gpio_direction_input(pdata->gpio_pin); 83 ret = gpio_direction_input(pdata->gpio_pin);
84 if (ret) { 84 if (ret) {
85 pr_warning("failed to set pin direction\n"); 85 pr_warning("failed to set pin direction\n");
86 gpio_free(pdata->gpio_pin);
87 return -EINVAL; 86 return -EINVAL;
88 } 87 }
89 88
@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
109 struct pps_gpio_device_data *data; 108 struct pps_gpio_device_data *data;
110 int irq; 109 int irq;
111 int ret; 110 int ret;
112 int err;
113 int pps_default_params; 111 int pps_default_params;
114 const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data; 112 const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
115 113
@@ -123,17 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev)
123 irq = gpio_to_irq(pdata->gpio_pin); 121 irq = gpio_to_irq(pdata->gpio_pin);
124 if (irq < 0) { 122 if (irq < 0) {
125 pr_err("failed to map GPIO to IRQ: %d\n", irq); 123 pr_err("failed to map GPIO to IRQ: %d\n", irq);
126 err = -EINVAL; 124 return -EINVAL;
127 goto return_error;
128 } 125 }
129 126
130 /* allocate space for device info */ 127 /* allocate space for device info */
131 data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data), 128 data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data),
132 GFP_KERNEL); 129 GFP_KERNEL);
133 if (data == NULL) { 130 if (data == NULL)
134 err = -ENOMEM; 131 return -ENOMEM;
135 goto return_error;
136 }
137 132
138 /* initialize PPS specific parts of the bookkeeping data structure. */ 133 /* initialize PPS specific parts of the bookkeeping data structure. */
139 data->info.mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT | 134 data->info.mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT |
@@ -152,41 +147,32 @@ static int pps_gpio_probe(struct platform_device *pdev)
152 data->pps = pps_register_source(&data->info, pps_default_params); 147 data->pps = pps_register_source(&data->info, pps_default_params);
153 if (data->pps == NULL) { 148 if (data->pps == NULL) {
154 pr_err("failed to register IRQ %d as PPS source\n", irq); 149 pr_err("failed to register IRQ %d as PPS source\n", irq);
155 err = -EINVAL; 150 return -EINVAL;
156 goto return_error;
157 } 151 }
158 152
159 data->irq = irq; 153 data->irq = irq;
160 data->pdata = pdata; 154 data->pdata = pdata;
161 155
162 /* register IRQ interrupt handler */ 156 /* register IRQ interrupt handler */
163 ret = request_irq(irq, pps_gpio_irq_handler, 157 ret = devm_request_irq(&pdev->dev, irq, pps_gpio_irq_handler,
164 get_irqf_trigger_flags(pdata), data->info.name, data); 158 get_irqf_trigger_flags(pdata), data->info.name, data);
165 if (ret) { 159 if (ret) {
166 pps_unregister_source(data->pps); 160 pps_unregister_source(data->pps);
167 pr_err("failed to acquire IRQ %d\n", irq); 161 pr_err("failed to acquire IRQ %d\n", irq);
168 err = -EINVAL; 162 return -EINVAL;
169 goto return_error;
170 } 163 }
171 164
172 platform_set_drvdata(pdev, data); 165 platform_set_drvdata(pdev, data);
173 dev_info(data->pps->dev, "Registered IRQ %d as PPS source\n", irq); 166 dev_info(data->pps->dev, "Registered IRQ %d as PPS source\n", irq);
174 167
175 return 0; 168 return 0;
176
177return_error:
178 gpio_free(pdata->gpio_pin);
179 return err;
180} 169}
181 170
182static int pps_gpio_remove(struct platform_device *pdev) 171static int pps_gpio_remove(struct platform_device *pdev)
183{ 172{
184 struct pps_gpio_device_data *data = platform_get_drvdata(pdev); 173 struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
185 const struct pps_gpio_platform_data *pdata = data->pdata;
186 174
187 platform_set_drvdata(pdev, NULL); 175 platform_set_drvdata(pdev, NULL);
188 free_irq(data->irq, data);
189 gpio_free(pdata->gpio_pin);
190 pps_unregister_source(data->pps); 176 pps_unregister_source(data->pps);
191 pr_info("removed IRQ %d as PPS source\n", data->irq); 177 pr_info("removed IRQ %d as PPS source\n", data->irq);
192 return 0; 178 return 0;