NVIDIA: SAUCE: mmc: core: separate mmc_test and mmc driver
BugLink: https://bugs.launchpad.net/bugs/2072591 The mmc_test and mmc driver were currently linked in code. Separate out the probe of mmc_test from that of the core mmc driver. http://nvbugs/200318024 Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com> Reviewed-by: Kasinadha Dendukuri <kdendukuri@nvidia.com> Reviewed-by: Sandeep Trasi <strasi@nvidia.com> Tested-by: Manish Bhardwaj <mbhardwaj@nvidia.com> Tested-by: Kasinadha Dendukuri <kdendukuri@nvidia.com> Tested-by: Abhilash G <abhilashg@nvidia.com> Reviewed-by: Abhilash G <abhilashg@nvidia.com> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Jacob Martin <jacob.martin@canonical.com> Acked-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Noah Wager <noah.wager@canonical.com>
This commit is contained in:
committed by
Noah Wager
parent
3e3f3a4ca8
commit
a2be2a8e79
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2003 Russell King, All Rights Reserved.
|
||||
* Copyright (C) 2007 Pierre Ossman
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* MMC card bus driver model
|
||||
*/
|
||||
@@ -28,6 +29,11 @@
|
||||
|
||||
#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv)
|
||||
|
||||
struct mmc_card *mmc_cards[MAX_CARDS_NUM];
|
||||
EXPORT_SYMBOL(mmc_cards);
|
||||
|
||||
static int card_idx;
|
||||
|
||||
static ssize_t type_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
@@ -128,6 +134,13 @@ static int mmc_bus_probe(struct device *dev)
|
||||
struct mmc_driver *drv = to_mmc_driver(dev->driver);
|
||||
struct mmc_card *card = mmc_dev_to_card(dev);
|
||||
|
||||
if (card_idx == MAX_CARDS_NUM) {
|
||||
pr_err("Exceeded the total number of cards allowed");
|
||||
return -EINVAL;
|
||||
} else {
|
||||
mmc_cards[card_idx++] = card;
|
||||
}
|
||||
|
||||
return drv->probe(card);
|
||||
}
|
||||
|
||||
|
||||
+16
-13
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright 2007-2008 Pierre Ossman
|
||||
* Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/mmc/core.h>
|
||||
@@ -3269,29 +3270,31 @@ static void mmc_test_remove(struct mmc_card *card)
|
||||
mmc_test_free_dbgfs_file(card);
|
||||
}
|
||||
|
||||
static struct mmc_driver mmc_driver = {
|
||||
.drv = {
|
||||
.name = "mmc_test",
|
||||
},
|
||||
.probe = mmc_test_probe,
|
||||
.remove = mmc_test_remove,
|
||||
};
|
||||
|
||||
static int __init mmc_test_init(void)
|
||||
static int mmc_test_init(void)
|
||||
{
|
||||
return mmc_register_driver(&mmc_driver);
|
||||
int card_idx;
|
||||
|
||||
for (card_idx = 0; card_idx < MAX_CARDS_NUM; card_idx++) {
|
||||
if (mmc_cards[card_idx] != NULL)
|
||||
mmc_test_probe(mmc_cards[card_idx]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit mmc_test_exit(void)
|
||||
{
|
||||
int card_idx;
|
||||
|
||||
for (card_idx = 0; card_idx < MAX_CARDS_NUM; card_idx++) {
|
||||
if (mmc_cards[card_idx] != NULL)
|
||||
mmc_test_remove(mmc_cards[card_idx]);
|
||||
}
|
||||
/* Clear stalled data if card is still plugged */
|
||||
mmc_test_free_result(NULL);
|
||||
mmc_test_free_dbgfs_file(NULL);
|
||||
|
||||
mmc_unregister_driver(&mmc_driver);
|
||||
}
|
||||
|
||||
module_init(mmc_test_init);
|
||||
late_initcall(mmc_test_init);
|
||||
module_exit(mmc_test_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
/*
|
||||
* linux/include/linux/mmc/card.h
|
||||
*
|
||||
* Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Card driver specific definitions.
|
||||
*/
|
||||
#ifndef LINUX_MMC_CARD_H
|
||||
@@ -10,6 +12,7 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
|
||||
#define MAX_CARDS_NUM 4
|
||||
struct mmc_cid {
|
||||
unsigned int manfid;
|
||||
char prod_name[8];
|
||||
@@ -353,6 +356,8 @@ static inline int mmc_card_enable_async_irq(struct mmc_card *card)
|
||||
return card->cccr.enable_async_irq;
|
||||
}
|
||||
|
||||
extern struct mmc_card *mmc_cards[MAX_CARDS_NUM];
|
||||
|
||||
bool mmc_card_is_blockaddr(struct mmc_card *card);
|
||||
|
||||
#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
|
||||
|
||||
Reference in New Issue
Block a user