Skip to content

Commit 3ae5eae

Browse files
Russell KingRussell King
authored andcommitted
[DRIVER MODEL] Convert platform drivers to use struct platform_driver
This allows us to eliminate the casts in the drivers, and eventually remove the use of the device_driver function pointer methods for platform device drivers. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 00d3dcd commit 3ae5eae

93 files changed

Lines changed: 1413 additions & 1416 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/arm/common/locomo.c‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,17 @@ struct locomo_save_data {
550550
u16 LCM_SPIMD;
551551
};
552552

553-
static int locomo_suspend(struct device *dev, pm_message_t state)
553+
static int locomo_suspend(struct platform_device *dev, pm_message_t state)
554554
{
555-
struct locomo *lchip = dev_get_drvdata(dev);
555+
struct locomo *lchip = platform_get_drvdata(dev);
556556
struct locomo_save_data *save;
557557
unsigned long flags;
558558

559559
save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL);
560560
if (!save)
561561
return -ENOMEM;
562562

563-
dev->power.saved_state = (void *) save;
563+
dev->dev.power.saved_state = (void *) save;
564564

565565
spin_lock_irqsave(&lchip->lock, flags);
566566

@@ -594,14 +594,14 @@ static int locomo_suspend(struct device *dev, pm_message_t state)
594594
return 0;
595595
}
596596

597-
static int locomo_resume(struct device *dev)
597+
static int locomo_resume(struct platform_device *dev)
598598
{
599-
struct locomo *lchip = dev_get_drvdata(dev);
599+
struct locomo *lchip = platform_get_drvdata(dev);
600600
struct locomo_save_data *save;
601601
unsigned long r;
602602
unsigned long flags;
603603

604-
save = (struct locomo_save_data *) dev->power.saved_state;
604+
save = (struct locomo_save_data *) dev->dev.power.saved_state;
605605
if (!save)
606606
return 0;
607607

@@ -760,27 +760,26 @@ static void __locomo_remove(struct locomo *lchip)
760760
kfree(lchip);
761761
}
762762

763-
static int locomo_probe(struct device *dev)
763+
static int locomo_probe(struct platform_device *dev)
764764
{
765-
struct platform_device *pdev = to_platform_device(dev);
766765
struct resource *mem;
767766
int irq;
768767

769-
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
768+
mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
770769
if (!mem)
771770
return -EINVAL;
772-
irq = platform_get_irq(pdev, 0);
771+
irq = platform_get_irq(dev, 0);
773772

774-
return __locomo_probe(dev, mem, irq);
773+
return __locomo_probe(&dev->dev, mem, irq);
775774
}
776775

777-
static int locomo_remove(struct device *dev)
776+
static int locomo_remove(struct platform_device *dev)
778777
{
779-
struct locomo *lchip = dev_get_drvdata(dev);
778+
struct locomo *lchip = platform__get_drvdata(dev);
780779

781780
if (lchip) {
782781
__locomo_remove(lchip);
783-
dev_set_drvdata(dev, NULL);
782+
platform_set_drvdata(dev, NULL);
784783
}
785784

786785
return 0;
@@ -792,15 +791,16 @@ static int locomo_remove(struct device *dev)
792791
* the per-machine level, and then have this driver pick
793792
* up the registered devices.
794793
*/
795-
static struct device_driver locomo_device_driver = {
796-
.name = "locomo",
797-
.bus = &platform_bus_type,
794+
static struct platform_driver locomo_device_driver = {
798795
.probe = locomo_probe,
799796
.remove = locomo_remove,
800797
#ifdef CONFIG_PM
801798
.suspend = locomo_suspend,
802799
.resume = locomo_resume,
803800
#endif
801+
.driver = {
802+
.name = "locomo",
803+
},
804804
};
805805

806806
/*
@@ -1126,13 +1126,13 @@ static int __init locomo_init(void)
11261126
{
11271127
int ret = bus_register(&locomo_bus_type);
11281128
if (ret == 0)
1129-
driver_register(&locomo_device_driver);
1129+
platform_driver_register(&locomo_device_driver);
11301130
return ret;
11311131
}
11321132

11331133
static void __exit locomo_exit(void)
11341134
{
1135-
driver_unregister(&locomo_device_driver);
1135+
platform_driver_unregister(&locomo_device_driver);
11361136
bus_unregister(&locomo_bus_type);
11371137
}
11381138

‎arch/arm/common/sa1111.c‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -801,9 +801,9 @@ struct sa1111_save_data {
801801

802802
#ifdef CONFIG_PM
803803

804-
static int sa1111_suspend(struct device *dev, pm_message_t state)
804+
static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
805805
{
806-
struct sa1111 *sachip = dev_get_drvdata(dev);
806+
struct sa1111 *sachip = platform_get_drvdata(dev);
807807
struct sa1111_save_data *save;
808808
unsigned long flags;
809809
unsigned int val;
@@ -812,7 +812,7 @@ static int sa1111_suspend(struct device *dev, pm_message_t state)
812812
save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
813813
if (!save)
814814
return -ENOMEM;
815-
dev->power.saved_state = save;
815+
dev->dev.power.saved_state = save;
816816

817817
spin_lock_irqsave(&sachip->lock, flags);
818818

@@ -859,14 +859,14 @@ static int sa1111_suspend(struct device *dev, pm_message_t state)
859859
* restored by their respective drivers, and must be called
860860
* via LDM after this function.
861861
*/
862-
static int sa1111_resume(struct device *dev)
862+
static int sa1111_resume(struct platform_device *dev)
863863
{
864-
struct sa1111 *sachip = dev_get_drvdata(dev);
864+
struct sa1111 *sachip = platform_get_drvdata(dev);
865865
struct sa1111_save_data *save;
866866
unsigned long flags, id;
867867
void __iomem *base;
868868

869-
save = (struct sa1111_save_data *)dev->power.saved_state;
869+
save = (struct sa1111_save_data *)dev->dev.power.saved_state;
870870
if (!save)
871871
return 0;
872872

@@ -879,7 +879,7 @@ static int sa1111_resume(struct device *dev)
879879
id = sa1111_readl(sachip->base + SA1111_SKID);
880880
if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
881881
__sa1111_remove(sachip);
882-
dev_set_drvdata(dev, NULL);
882+
platform_set_drvdata(dev, NULL);
883883
kfree(save);
884884
return 0;
885885
}
@@ -911,7 +911,7 @@ static int sa1111_resume(struct device *dev)
911911

912912
spin_unlock_irqrestore(&sachip->lock, flags);
913913

914-
dev->power.saved_state = NULL;
914+
dev->dev.power.saved_state = NULL;
915915
kfree(save);
916916

917917
return 0;
@@ -922,9 +922,8 @@ static int sa1111_resume(struct device *dev)
922922
#define sa1111_resume NULL
923923
#endif
924924

925-
static int sa1111_probe(struct device *dev)
925+
static int sa1111_probe(struct platform_device *pdev)
926926
{
927-
struct platform_device *pdev = to_platform_device(dev);
928927
struct resource *mem;
929928
int irq;
930929

@@ -933,20 +932,20 @@ static int sa1111_probe(struct device *dev)
933932
return -EINVAL;
934933
irq = platform_get_irq(pdev, 0);
935934

936-
return __sa1111_probe(dev, mem, irq);
935+
return __sa1111_probe(&pdev->dev, mem, irq);
937936
}
938937

939-
static int sa1111_remove(struct device *dev)
938+
static int sa1111_remove(struct platform_device *pdev)
940939
{
941-
struct sa1111 *sachip = dev_get_drvdata(dev);
940+
struct sa1111 *sachip = platform_get_drvdata(pdev);
942941

943942
if (sachip) {
944943
__sa1111_remove(sachip);
945-
dev_set_drvdata(dev, NULL);
944+
platform_set_drvdata(pdev, NULL);
946945

947946
#ifdef CONFIG_PM
948-
kfree(dev->power.saved_state);
949-
dev->power.saved_state = NULL;
947+
kfree(pdev->dev.power.saved_state);
948+
pdev->dev.power.saved_state = NULL;
950949
#endif
951950
}
952951

@@ -962,13 +961,14 @@ static int sa1111_remove(struct device *dev)
962961
* We also need to handle the SDRAM configuration for
963962
* PXA250/SA1110 machine classes.
964963
*/
965-
static struct device_driver sa1111_device_driver = {
966-
.name = "sa1111",
967-
.bus = &platform_bus_type,
964+
static struct platform_driver sa1111_device_driver = {
968965
.probe = sa1111_probe,
969966
.remove = sa1111_remove,
970967
.suspend = sa1111_suspend,
971968
.resume = sa1111_resume,
969+
.driver = {
970+
.name = "sa1111",
971+
},
972972
};
973973

974974
/*
@@ -1256,13 +1256,13 @@ static int __init sa1111_init(void)
12561256
{
12571257
int ret = bus_register(&sa1111_bus_type);
12581258
if (ret == 0)
1259-
driver_register(&sa1111_device_driver);
1259+
platform_driver_register(&sa1111_device_driver);
12601260
return ret;
12611261
}
12621262

12631263
static void __exit sa1111_exit(void)
12641264
{
1265-
driver_unregister(&sa1111_device_driver);
1265+
platform_driver_unregister(&sa1111_device_driver);
12661266
bus_unregister(&sa1111_bus_type);
12671267
}
12681268

‎arch/arm/common/scoop.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ static void check_scoop_reg(struct scoop_dev *sdev)
9898
}
9999

100100
#ifdef CONFIG_PM
101-
static int scoop_suspend(struct device *dev, pm_message_t state)
101+
static int scoop_suspend(struct platform_device *dev, pm_message_t state)
102102
{
103-
struct scoop_dev *sdev = dev_get_drvdata(dev);
103+
struct scoop_dev *sdev = platform_get_drvdata(dev);
104104

105105
check_scoop_reg(sdev);
106106
sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR);
@@ -109,9 +109,9 @@ static int scoop_suspend(struct device *dev, pm_message_t state)
109109
return 0;
110110
}
111111

112-
static int scoop_resume(struct device *dev)
112+
static int scoop_resume(struct platform_device *dev)
113113
{
114-
struct scoop_dev *sdev = dev_get_drvdata(dev);
114+
struct scoop_dev *sdev = platform_get_drvdata(dev);
115115

116116
check_scoop_reg(sdev);
117117
SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr;
@@ -123,11 +123,10 @@ static int scoop_resume(struct device *dev)
123123
#define scoop_resume NULL
124124
#endif
125125

126-
int __init scoop_probe(struct device *dev)
126+
int __init scoop_probe(struct platform_device *pdev)
127127
{
128128
struct scoop_dev *devptr;
129129
struct scoop_config *inf;
130-
struct platform_device *pdev = to_platform_device(dev);
131130
struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
132131

133132
if (!mem)
@@ -141,15 +140,15 @@ int __init scoop_probe(struct device *dev)
141140
memset(devptr, 0, sizeof(struct scoop_dev));
142141
spin_lock_init(&devptr->scoop_lock);
143142

144-
inf = dev->platform_data;
143+
inf = pdev->dev.platform_data;
145144
devptr->base = ioremap(mem->start, mem->end - mem->start + 1);
146145

147146
if (!devptr->base) {
148147
kfree(devptr);
149148
return -ENOMEM;
150149
}
151150

152-
dev_set_drvdata(dev, devptr);
151+
platform_set_drvdata(pdev, devptr);
153152

154153
printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base);
155154

@@ -164,29 +163,30 @@ int __init scoop_probe(struct device *dev)
164163
return 0;
165164
}
166165

167-
static int scoop_remove(struct device *dev)
166+
static int scoop_remove(struct platform_device *pdev)
168167
{
169-
struct scoop_dev *sdev = dev_get_drvdata(dev);
168+
struct scoop_dev *sdev = platform_get_drvdata(pdev);
170169
if (sdev) {
171170
iounmap(sdev->base);
172171
kfree(sdev);
173-
dev_set_drvdata(dev, NULL);
172+
platform_set_drvdata(pdev, NULL);
174173
}
175174
return 0;
176175
}
177176

178-
static struct device_driver scoop_driver = {
179-
.name = "sharp-scoop",
180-
.bus = &platform_bus_type,
177+
static struct platform_driver scoop_driver = {
181178
.probe = scoop_probe,
182179
.remove = scoop_remove,
183180
.suspend = scoop_suspend,
184181
.resume = scoop_resume,
182+
.driver = {
183+
.name = "sharp-scoop",
184+
},
185185
};
186186

187187
int __init scoop_init(void)
188188
{
189-
return driver_register(&scoop_driver);
189+
return platform_driver_register(&scoop_driver);
190190
}
191191

192192
subsys_initcall(scoop_init);

‎arch/arm/mach-pxa/corgi_ssp.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
191191
ssp_machinfo = machinfo;
192192
}
193193

194-
static int __init corgi_ssp_probe(struct device *dev)
194+
static int __init corgi_ssp_probe(struct platform_device *dev)
195195
{
196196
int ret;
197197

@@ -216,21 +216,21 @@ static int __init corgi_ssp_probe(struct device *dev)
216216
return ret;
217217
}
218218

219-
static int corgi_ssp_remove(struct device *dev)
219+
static int corgi_ssp_remove(struct platform_device *dev)
220220
{
221221
ssp_exit(&corgi_ssp_dev);
222222
return 0;
223223
}
224224

225-
static int corgi_ssp_suspend(struct device *dev, pm_message_t state)
225+
static int corgi_ssp_suspend(struct platform_device *dev, pm_message_t state)
226226
{
227227
ssp_flush(&corgi_ssp_dev);
228228
ssp_save_state(&corgi_ssp_dev,&corgi_ssp_state);
229229

230230
return 0;
231231
}
232232

233-
static int corgi_ssp_resume(struct device *dev)
233+
static int corgi_ssp_resume(struct platform_device *dev)
234234
{
235235
GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */
236236
GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/
@@ -241,18 +241,19 @@ static int corgi_ssp_resume(struct device *dev)
241241
return 0;
242242
}
243243

244-
static struct device_driver corgissp_driver = {
245-
.name = "corgi-ssp",
246-
.bus = &platform_bus_type,
244+
static struct platform_driver corgissp_driver = {
247245
.probe = corgi_ssp_probe,
248246
.remove = corgi_ssp_remove,
249247
.suspend = corgi_ssp_suspend,
250248
.resume = corgi_ssp_resume,
249+
.driver = {
250+
.name = "corgi-ssp",
251+
},
251252
};
252253

253254
int __init corgi_ssp_init(void)
254255
{
255-
return driver_register(&corgissp_driver);
256+
return platform_driver_register(&corgissp_driver);
256257
}
257258

258259
arch_initcall(corgi_ssp_init);

0 commit comments

Comments
 (0)