It appears that one of the supported platform magically worked with
the custom IRQ handler (any hints how?) while having two PCB designs
with an opposite CD sense level. Quirking it out reveals the code
duplication and dead code.
Patch 1 is code deduplication to save few LOCs.
Patch 2-5 are dead code removals.
In v3:
- dropped the fix as it has been applied (Ulf)
- added tag (Adrian)
- elaborated commit IDs with their short descriptions in patch 3 (Adrian)
- corrected dependency in patch 5 (Adrian)
In v2:
- redone fix to use ->get_cd() instead of quirks (Adrian)
- due to above transformed previous clean up to the current patch 2
- added a new patch, i.e. patch 3
- added commit IDs to patch 4 (Adrian)
- mentioned dependencies on previous patches in patch 5 and 6 (Adrian)
Andy Shevchenko (5):
mmc: sdhci: Deduplicate sdhci_get_cd_nogpio()
mmc: sdhci: Remove unused prototype declaration in the header
mmc: sdhci-pci: Remove dead code (struct sdhci_pci_data et al)
mmc: sdhci-pci: Remove dead code (cd_gpio, cd_irq et al)
mmc: sdhci-pci: Remove dead code (rst_n_gpio et al)
drivers/mmc/host/Makefile | 1 -
drivers/mmc/host/sdhci-acpi.c | 14 +--
drivers/mmc/host/sdhci-pci-core.c | 152 +----------------------------
drivers/mmc/host/sdhci-pci-data.c | 6 --
drivers/mmc/host/sdhci-pci.h | 5 -
drivers/mmc/host/sdhci.c | 19 ++++
drivers/mmc/host/sdhci.h | 2 +-
include/linux/mmc/sdhci-pci-data.h | 18 ----
8 files changed, 26 insertions(+), 191 deletions(-)
delete mode 100644 drivers/mmc/host/sdhci-pci-data.c
delete mode 100644 include/linux/mmc/sdhci-pci-data.h
--
2.33.0
The last user of this struct gone a couple of releases ago.
Besides that there were not so many users of this API for
more than 10 years:
1/ The one is Intel Merrifield, that had been added 2016-08-31
by the commit 3976b0380b31 ("x86/platform/intel-mid: Enable
SD card detection on Merrifield") and removed 2021-02-11 by
the commit 4590d98f5a4f ("sfi: Remove framework for deprecated
firmware").
2/ The other is Intel Sunrisepoint related, that had been added
2015-02-06 by the commit e1bfad6d936d ("mmc: sdhci-pci: Add
support for drive strength selection for SPT") and removed
2017-03-20 by the commit 51ced59cc02e ("mmc: sdhci-pci: Use
ACPI DSM to get driver strength for some Intel devices").
Effectively this is a revert of the commit 52c506f0bc72 ("mmc:
sdhci-pci: add platform data").
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
---
drivers/mmc/host/Makefile | 1 -
drivers/mmc/host/sdhci-pci-core.c | 31 ++++--------------------------
drivers/mmc/host/sdhci-pci-data.c | 6 ------
drivers/mmc/host/sdhci-pci.h | 1 -
include/linux/mmc/sdhci-pci-data.h | 18 -----------------
5 files changed, 4 insertions(+), 53 deletions(-)
delete mode 100644 drivers/mmc/host/sdhci-pci-data.c
delete mode 100644 include/linux/mmc/sdhci-pci-data.h
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 14004cc09aaa..ea36d379bd3c 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -14,7 +14,6 @@ obj-$(CONFIG_MMC_SDHCI) += sdhci.o
obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o
sdhci-pci-y += sdhci-pci-core.o sdhci-pci-o2micro.o sdhci-pci-arasan.o \
sdhci-pci-dwc-mshc.o sdhci-pci-gli.o
-obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += sdhci-pci-data.o
obj-$(CONFIG_MMC_SDHCI_ACPI) += sdhci-acpi.o
obj-$(CONFIG_MMC_SDHCI_PXAV3) += sdhci-pxav3.o
obj-$(CONFIG_MMC_SDHCI_PXAV2) += sdhci-pxav2.o
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 19e13dfae593..8938c63b1e77 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -17,8 +17,6 @@
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/device.h>
-#include <linux/mmc/host.h>
-#include <linux/mmc/mmc.h>
#include <linux/scatterlist.h>
#include <linux/io.h>
#include <linux/iopoll.h>
@@ -26,11 +24,13 @@
#include <linux/pm_runtime.h>
#include <linux/pm_qos.h>
#include <linux/debugfs.h>
-#include <linux/mmc/slot-gpio.h>
-#include <linux/mmc/sdhci-pci-data.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/mmc/slot-gpio.h>
+
#ifdef CONFIG_X86
#include <asm/iosf_mbi.h>
#endif
@@ -2131,22 +2131,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
slot->cd_gpio = -EINVAL;
slot->cd_idx = -1;
- /* Retrieve platform data if there is any */
- if (*sdhci_pci_get_data)
- slot->data = sdhci_pci_get_data(pdev, slotno);
-
- if (slot->data) {
- if (slot->data->setup) {
- ret = slot->data->setup(slot->data);
- if (ret) {
- dev_err(&pdev->dev, "platform setup failed\n");
- goto free;
- }
- }
- slot->rst_n_gpio = slot->data->rst_n_gpio;
- slot->cd_gpio = slot->data->cd_gpio;
- }
-
host->hw_name = "PCI";
host->ops = chip->fixes && chip->fixes->ops ?
chip->fixes->ops :
@@ -2233,10 +2217,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
chip->fixes->remove_slot(slot, 0);
cleanup:
- if (slot->data && slot->data->cleanup)
- slot->data->cleanup(slot->data);
-
-free:
sdhci_free_host(host);
return ERR_PTR(ret);
@@ -2259,9 +2239,6 @@ static void sdhci_pci_remove_slot(struct sdhci_pci_slot *slot)
if (slot->chip->fixes && slot->chip->fixes->remove_slot)
slot->chip->fixes->remove_slot(slot, dead);
- if (slot->data && slot->data->cleanup)
- slot->data->cleanup(slot->data);
-
sdhci_free_host(slot->host);
}
diff --git a/drivers/mmc/host/sdhci-pci-data.c b/drivers/mmc/host/sdhci-pci-data.c
deleted file mode 100644
index 18638fb363d8..000000000000
--- a/drivers/mmc/host/sdhci-pci-data.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include <linux/module.h>
-#include <linux/mmc/sdhci-pci-data.h>
-
-struct sdhci_pci_data *(*sdhci_pci_get_data)(struct pci_dev *pdev, int slotno);
-EXPORT_SYMBOL_GPL(sdhci_pci_get_data);
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 8f90c4163bb5..15b36cd47860 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -156,7 +156,6 @@ struct sdhci_pci_fixes {
struct sdhci_pci_slot {
struct sdhci_pci_chip *chip;
struct sdhci_host *host;
- struct sdhci_pci_data *data;
int rst_n_gpio;
int cd_gpio;
diff --git a/include/linux/mmc/sdhci-pci-data.h b/include/linux/mmc/sdhci-pci-data.h
deleted file mode 100644
index 1d42872d22f3..000000000000
--- a/include/linux/mmc/sdhci-pci-data.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef LINUX_MMC_SDHCI_PCI_DATA_H
-#define LINUX_MMC_SDHCI_PCI_DATA_H
-
-struct pci_dev;
-
-struct sdhci_pci_data {
- struct pci_dev *pdev;
- int slotno;
- int rst_n_gpio; /* Set to -EINVAL if unused */
- int cd_gpio; /* Set to -EINVAL if unused */
- int (*setup)(struct sdhci_pci_data *data);
- void (*cleanup)(struct sdhci_pci_data *data);
-};
-
-extern struct sdhci_pci_data *(*sdhci_pci_get_data)(struct pci_dev *pdev,
- int slotno);
-#endif
--
2.33.0
There is no user of this member. Remove the dead code for good.
The removal is dependent on the previous removal of the
struct sdhci_pci_data.
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
---
drivers/mmc/host/sdhci-pci-core.c | 27 ---------------------------
drivers/mmc/host/sdhci-pci.h | 2 --
2 files changed, 29 deletions(-)
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index e2b6f60e9f01..6f9877546830 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -1915,21 +1915,6 @@ int sdhci_pci_enable_dma(struct sdhci_host *host)
return 0;
}
-static void sdhci_pci_gpio_hw_reset(struct sdhci_host *host)
-{
- struct sdhci_pci_slot *slot = sdhci_priv(host);
- int rst_n_gpio = slot->rst_n_gpio;
-
- if (!gpio_is_valid(rst_n_gpio))
- return;
- gpio_set_value_cansleep(rst_n_gpio, 0);
- /* For eMMC, minimum is 1us but give it 10us for good measure */
- udelay(10);
- gpio_set_value_cansleep(rst_n_gpio, 1);
- /* For eMMC, minimum is 200us but give it 300us for good measure */
- usleep_range(300, 1000);
-}
-
static void sdhci_pci_hw_reset(struct sdhci_host *host)
{
struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -2060,7 +2045,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
slot->chip = chip;
slot->host = host;
- slot->rst_n_gpio = -EINVAL;
slot->cd_idx = -1;
host->hw_name = "PCI";
@@ -2086,17 +2070,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
goto cleanup;
}
- if (gpio_is_valid(slot->rst_n_gpio)) {
- if (!devm_gpio_request(&pdev->dev, slot->rst_n_gpio, "eMMC_reset")) {
- gpio_direction_output(slot->rst_n_gpio, 1);
- slot->host->mmc->caps |= MMC_CAP_HW_RESET;
- slot->hw_reset = sdhci_pci_gpio_hw_reset;
- } else {
- dev_warn(&pdev->dev, "failed to request rst_n_gpio\n");
- slot->rst_n_gpio = -EINVAL;
- }
- }
-
host->mmc->pm_caps = MMC_PM_KEEP_POWER;
host->mmc->slotno = slotno;
host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 8bb3b9c78589..5e3193278ff9 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -157,8 +157,6 @@ struct sdhci_pci_slot {
struct sdhci_pci_chip *chip;
struct sdhci_host *host;
- int rst_n_gpio;
-
int cd_idx;
bool cd_override_level;
--
2.33.0
sdhci_card_detect() is not defined anywhere. Remove it.
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
---
drivers/mmc/host/sdhci.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index c593af479832..bb883553d3b4 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -750,7 +750,6 @@ static inline void *sdhci_priv(struct sdhci_host *host)
return host->private;
}
-void sdhci_card_detect(struct sdhci_host *host);
void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
const u32 *caps, const u32 *caps1);
int sdhci_setup_host(struct sdhci_host *host);
--
2.33.0
The last user of this struct gone couple of releases ago.
Remove the dead code for good and encourage people to use
MMC core functionality for that.
The removal is dependent on the previous removal of the
struct sdhci_pci_data.
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
---
drivers/mmc/host/sdhci-pci-core.c | 76 +------------------------------
drivers/mmc/host/sdhci-pci.h | 2 -
2 files changed, 1 insertion(+), 77 deletions(-)
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 8938c63b1e77..e2b6f60e9f01 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -345,73 +345,6 @@ static int pch_hc_probe_slot(struct sdhci_pci_slot *slot)
return 0;
}
-#ifdef CONFIG_PM
-
-static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id)
-{
- struct sdhci_pci_slot *slot = dev_id;
- struct sdhci_host *host = slot->host;
-
- mmc_detect_change(host->mmc, msecs_to_jiffies(200));
- return IRQ_HANDLED;
-}
-
-static void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot)
-{
- int err, irq, gpio = slot->cd_gpio;
-
- slot->cd_gpio = -EINVAL;
- slot->cd_irq = -EINVAL;
-
- if (!gpio_is_valid(gpio))
- return;
-
- err = devm_gpio_request(&slot->chip->pdev->dev, gpio, "sd_cd");
- if (err < 0)
- goto out;
-
- err = gpio_direction_input(gpio);
- if (err < 0)
- goto out_free;
-
- irq = gpio_to_irq(gpio);
- if (irq < 0)
- goto out_free;
-
- err = request_irq(irq, sdhci_pci_sd_cd, IRQF_TRIGGER_RISING |
- IRQF_TRIGGER_FALLING, "sd_cd", slot);
- if (err)
- goto out_free;
-
- slot->cd_gpio = gpio;
- slot->cd_irq = irq;
-
- return;
-
-out_free:
- devm_gpio_free(&slot->chip->pdev->dev, gpio);
-out:
- dev_warn(&slot->chip->pdev->dev, "failed to setup card detect wake up\n");
-}
-
-static void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)
-{
- if (slot->cd_irq >= 0)
- free_irq(slot->cd_irq, slot);
-}
-
-#else
-
-static inline void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot)
-{
-}
-
-static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)
-{
-}
-
-#endif
-
static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot)
{
slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE;
@@ -2128,7 +2061,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
slot->chip = chip;
slot->host = host;
slot->rst_n_gpio = -EINVAL;
- slot->cd_gpio = -EINVAL;
slot->cd_idx = -1;
host->hw_name = "PCI";
@@ -2199,15 +2131,11 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
if (ret)
goto remove;
- sdhci_pci_add_own_cd(slot);
-
/*
* Check if the chip needs a separate GPIO for card detect to wake up
* from runtime suspend. If it is not there, don't allow runtime PM.
- * Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure.
*/
- if (chip->fixes && chip->fixes->own_cd_for_runtime_pm &&
- !gpio_is_valid(slot->cd_gpio) && slot->cd_idx < 0)
+ if (chip->fixes && chip->fixes->own_cd_for_runtime_pm && slot->cd_idx < 0)
chip->allow_runtime_pm = false;
return slot;
@@ -2227,8 +2155,6 @@ static void sdhci_pci_remove_slot(struct sdhci_pci_slot *slot)
int dead;
u32 scratch;
- sdhci_pci_remove_own_cd(slot);
-
dead = 0;
scratch = readl(slot->host->ioaddr + SDHCI_INT_STATUS);
if (scratch == (u32)-1)
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 15b36cd47860..8bb3b9c78589 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -158,8 +158,6 @@ struct sdhci_pci_slot {
struct sdhci_host *host;
int rst_n_gpio;
- int cd_gpio;
- int cd_irq;
int cd_idx;
bool cd_override_level;
--
2.33.0
On Thu, 14 Oct 2021 at 15:26, Andy Shevchenko
<[email protected]> wrote:
>
> It appears that one of the supported platform magically worked with
> the custom IRQ handler (any hints how?) while having two PCB designs
> with an opposite CD sense level. Quirking it out reveals the code
> duplication and dead code.
>
> Patch 1 is code deduplication to save few LOCs.
> Patch 2-5 are dead code removals.
>
> In v3:
> - dropped the fix as it has been applied (Ulf)
> - added tag (Adrian)
> - elaborated commit IDs with their short descriptions in patch 3 (Adrian)
> - corrected dependency in patch 5 (Adrian)
>
> In v2:
> - redone fix to use ->get_cd() instead of quirks (Adrian)
> - due to above transformed previous clean up to the current patch 2
> - added a new patch, i.e. patch 3
> - added commit IDs to patch 4 (Adrian)
> - mentioned dependencies on previous patches in patch 5 and 6 (Adrian)
>
> Andy Shevchenko (5):
> mmc: sdhci: Deduplicate sdhci_get_cd_nogpio()
> mmc: sdhci: Remove unused prototype declaration in the header
> mmc: sdhci-pci: Remove dead code (struct sdhci_pci_data et al)
> mmc: sdhci-pci: Remove dead code (cd_gpio, cd_irq et al)
> mmc: sdhci-pci: Remove dead code (rst_n_gpio et al)
>
> drivers/mmc/host/Makefile | 1 -
> drivers/mmc/host/sdhci-acpi.c | 14 +--
> drivers/mmc/host/sdhci-pci-core.c | 152 +----------------------------
> drivers/mmc/host/sdhci-pci-data.c | 6 --
> drivers/mmc/host/sdhci-pci.h | 5 -
> drivers/mmc/host/sdhci.c | 19 ++++
> drivers/mmc/host/sdhci.h | 2 +-
> include/linux/mmc/sdhci-pci-data.h | 18 ----
> 8 files changed, 26 insertions(+), 191 deletions(-)
> delete mode 100644 drivers/mmc/host/sdhci-pci-data.c
> delete mode 100644 include/linux/mmc/sdhci-pci-data.h
>
Applied for next, thanks!
Kind regards
Uffe
Hi,
Op 14-10-2021 om 15:26 schreef Andy Shevchenko:
> It appears that one of the supported platform magically worked with
> the custom IRQ handler (any hints how?) while having two PCB designs
> with an opposite CD sense level. Quirking it out reveals the code
> duplication and dead code.
>
> Patch 1 is code deduplication to save few LOCs.
> Patch 2-5 are dead code removals.
Tested-by: Ferry Toth <[email protected]> @ Intel Edison-Arduino board
> In v3:
> - dropped the fix as it has been applied (Ulf)
> - added tag (Adrian)
> - elaborated commit IDs with their short descriptions in patch 3 (Adrian)
> - corrected dependency in patch 5 (Adrian)
>
> In v2:
> - redone fix to use ->get_cd() instead of quirks (Adrian)
> - due to above transformed previous clean up to the current patch 2
> - added a new patch, i.e. patch 3
> - added commit IDs to patch 4 (Adrian)
> - mentioned dependencies on previous patches in patch 5 and 6 (Adrian)
>
> Andy Shevchenko (5):
> mmc: sdhci: Deduplicate sdhci_get_cd_nogpio()
> mmc: sdhci: Remove unused prototype declaration in the header
> mmc: sdhci-pci: Remove dead code (struct sdhci_pci_data et al)
> mmc: sdhci-pci: Remove dead code (cd_gpio, cd_irq et al)
> mmc: sdhci-pci: Remove dead code (rst_n_gpio et al)
>
> drivers/mmc/host/Makefile | 1 -
> drivers/mmc/host/sdhci-acpi.c | 14 +--
> drivers/mmc/host/sdhci-pci-core.c | 152 +----------------------------
> drivers/mmc/host/sdhci-pci-data.c | 6 --
> drivers/mmc/host/sdhci-pci.h | 5 -
> drivers/mmc/host/sdhci.c | 19 ++++
> drivers/mmc/host/sdhci.h | 2 +-
> include/linux/mmc/sdhci-pci-data.h | 18 ----
> 8 files changed, 26 insertions(+), 191 deletions(-)
> delete mode 100644 drivers/mmc/host/sdhci-pci-data.c
> delete mode 100644 include/linux/mmc/sdhci-pci-data.h
>