@@ -224,14 +224,6 @@ struct mci_slot_pdata {
224
224
bool non_removable ;
225
225
};
226
226
227
- /**
228
- * struct mci_platform_data - board-specific MMC/SDcard configuration
229
- * @slot: Per-slot configuration data.
230
- */
231
- struct mci_platform_data {
232
- struct mci_slot_pdata slot [ATMCI_MAX_NR_SLOTS ];
233
- };
234
-
235
227
struct atmel_mci_caps {
236
228
bool has_dma_conf_reg ;
237
229
bool has_pdc ;
@@ -297,6 +289,7 @@ struct atmel_mci_dma {
297
289
* @mapbase: Physical address of the MMIO registers.
298
290
* @mck: The peripheral bus clock hooked up to the MMC controller.
299
291
* @dev: Device associated with the MMC controller.
292
+ * @pdata: Per-slot configuration data.
300
293
* @slot: Slots sharing this MMC controller.
301
294
* @caps: MCI capabilities depending on MCI version.
302
295
* @prepare_data: function to setup MCI before data transfer which
@@ -375,6 +368,7 @@ struct atmel_mci {
375
368
struct clk * mck ;
376
369
struct device * dev ;
377
370
371
+ struct mci_slot_pdata pdata [ATMCI_MAX_NR_SLOTS ];
378
372
struct atmel_mci_slot * slot [ATMCI_MAX_NR_SLOTS ];
379
373
380
374
struct atmel_mci_caps caps ;
@@ -630,11 +624,11 @@ static const struct of_device_id atmci_dt_ids[] = {
630
624
631
625
MODULE_DEVICE_TABLE (of , atmci_dt_ids );
632
626
633
- static struct mci_platform_data * atmci_of_init (struct device * dev )
627
+ static int atmci_of_init (struct atmel_mci * host )
634
628
{
629
+ struct device * dev = host -> dev ;
635
630
struct device_node * np = dev -> of_node ;
636
631
struct device_node * cnp ;
637
- struct mci_platform_data * pdata ;
638
632
u32 slot_id ;
639
633
int err ;
640
634
@@ -643,10 +637,6 @@ static struct mci_platform_data *atmci_of_init(struct device *dev)
643
637
return ERR_PTR (- EINVAL );
644
638
}
645
639
646
- pdata = devm_kzalloc (dev , sizeof (* pdata ), GFP_KERNEL );
647
- if (!pdata )
648
- return ERR_PTR (- ENOMEM );
649
-
650
640
for_each_child_of_node (np , cnp ) {
651
641
if (of_property_read_u32 (cnp , "reg" , & slot_id )) {
652
642
dev_warn (dev , "reg property is missing for %pOF\n" , cnp );
@@ -661,38 +651,38 @@ static struct mci_platform_data *atmci_of_init(struct device *dev)
661
651
}
662
652
663
653
if (of_property_read_u32 (cnp , "bus-width" ,
664
- & pdata -> slot [slot_id ].bus_width ))
665
- pdata -> slot [slot_id ].bus_width = 1 ;
654
+ & host -> pdata [slot_id ].bus_width ))
655
+ host -> pdata [slot_id ].bus_width = 1 ;
666
656
667
- pdata -> slot [slot_id ].detect_pin =
657
+ host -> pdata [slot_id ].detect_pin =
668
658
devm_fwnode_gpiod_get (dev , of_fwnode_handle (cnp ),
669
659
"cd" , GPIOD_IN , "cd-gpios" );
670
- err = PTR_ERR_OR_ZERO (pdata -> slot [slot_id ].detect_pin );
660
+ err = PTR_ERR_OR_ZERO (host -> pdata [slot_id ].detect_pin );
671
661
if (err ) {
672
662
if (err != - ENOENT ) {
673
663
of_node_put (cnp );
674
- return ERR_PTR ( err ) ;
664
+ return err ;
675
665
}
676
- pdata -> slot [slot_id ].detect_pin = NULL ;
666
+ host -> pdata [slot_id ].detect_pin = NULL ;
677
667
}
678
668
679
- pdata -> slot [slot_id ].non_removable =
669
+ host -> pdata [slot_id ].non_removable =
680
670
of_property_read_bool (cnp , "non-removable" );
681
671
682
- pdata -> slot [slot_id ].wp_pin =
672
+ host -> pdata [slot_id ].wp_pin =
683
673
devm_fwnode_gpiod_get (dev , of_fwnode_handle (cnp ),
684
674
"wp" , GPIOD_IN , "wp-gpios" );
685
- err = PTR_ERR_OR_ZERO (pdata -> slot [slot_id ].wp_pin );
675
+ err = PTR_ERR_OR_ZERO (host -> pdata [slot_id ].wp_pin );
686
676
if (err ) {
687
677
if (err != - ENOENT ) {
688
678
of_node_put (cnp );
689
- return ERR_PTR ( err ) ;
679
+ return err ;
690
680
}
691
- pdata -> slot [slot_id ].wp_pin = NULL ;
681
+ host -> pdata [slot_id ].wp_pin = NULL ;
692
682
}
693
683
}
694
684
695
- return pdata ;
685
+ return 0 ;
696
686
}
697
687
698
688
static inline unsigned int atmci_get_version (struct atmel_mci * host )
@@ -2456,7 +2446,6 @@ static void atmci_get_cap(struct atmel_mci *host)
2456
2446
static int atmci_probe (struct platform_device * pdev )
2457
2447
{
2458
2448
struct device * dev = & pdev -> dev ;
2459
- struct mci_platform_data * pdata ;
2460
2449
struct atmel_mci * host ;
2461
2450
struct resource * regs ;
2462
2451
unsigned int nr_slots ;
@@ -2467,12 +2456,6 @@ static int atmci_probe(struct platform_device *pdev)
2467
2456
if (!regs )
2468
2457
return - ENXIO ;
2469
2458
2470
- pdata = atmci_of_init (dev );
2471
- if (IS_ERR (pdata )) {
2472
- dev_err (dev , "platform data not available\n" );
2473
- return PTR_ERR (pdata );
2474
- }
2475
-
2476
2459
irq = platform_get_irq (pdev , 0 );
2477
2460
if (irq < 0 )
2478
2461
return irq ;
@@ -2485,6 +2468,10 @@ static int atmci_probe(struct platform_device *pdev)
2485
2468
spin_lock_init (& host -> lock );
2486
2469
INIT_LIST_HEAD (& host -> queue );
2487
2470
2471
+ ret = atmci_of_init (host );
2472
+ if (ret )
2473
+ return dev_err_probe (dev , ret , "Slot information not available\n" );
2474
+
2488
2475
host -> mck = devm_clk_get (dev , "mci_clk" );
2489
2476
if (IS_ERR (host -> mck ))
2490
2477
return PTR_ERR (host -> mck );
@@ -2544,16 +2531,16 @@ static int atmci_probe(struct platform_device *pdev)
2544
2531
/* We need at least one slot to succeed */
2545
2532
nr_slots = 0 ;
2546
2533
ret = - ENODEV ;
2547
- if (pdata -> slot [0 ].bus_width ) {
2548
- ret = atmci_init_slot (host , & pdata -> slot [0 ],
2534
+ if (host -> pdata [0 ].bus_width ) {
2535
+ ret = atmci_init_slot (host , & host -> pdata [0 ],
2549
2536
0 , ATMCI_SDCSEL_SLOT_A , ATMCI_SDIOIRQA );
2550
2537
if (!ret ) {
2551
2538
nr_slots ++ ;
2552
2539
host -> buf_size = host -> slot [0 ]-> mmc -> max_req_size ;
2553
2540
}
2554
2541
}
2555
- if (pdata -> slot [1 ].bus_width ) {
2556
- ret = atmci_init_slot (host , & pdata -> slot [1 ],
2542
+ if (host -> pdata [1 ].bus_width ) {
2543
+ ret = atmci_init_slot (host , & host -> pdata [1 ],
2557
2544
1 , ATMCI_SDCSEL_SLOT_B , ATMCI_SDIOIRQB );
2558
2545
if (!ret ) {
2559
2546
nr_slots ++ ;
0 commit comments