Skip to contentSkip to conversation

mmc: core: A start to slim down public mmc headers

PATCH In review Ulf Hansson 5 participants 38 messages Jan 13, 2017 – Jan 24, 2017

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v3 cover mmc: core: A start to slim down public mmc headers

Changes in v3:
- As patch 1 was applied from version 2, it has been dropped from the series.
- Folded in a four new changes in patch 1->4/15, to solve build issues for davinci, mips and pxa.

Changes in v2:
- As patch 1->11 was applied from version 1, those have been dropped from the series.
- Folded in a new change in patch 1/12, to solve a build issue for imx which is using the mxcmmc platform data header.
- Added reviews/acks.

Ideally we should not expose functions nor structures as being public available as the interface for mmc - unless they really are intended to be used like that.

Unfortunate this is not the case today and which has lead to the mmc interface in some cases being abused. That of course has its own problems, but we can still move things in the right direction, which is what this series intend to do. More precisely, it moves things that can be easily moved from the public mmc headers to the private mmc headers.

This should be considered as a first step of improving the situation, further additional changes will have to continue this path.

Ulf Hansson (15):
ARM: pxa: Don't rely on public mmc header to include leds.h
ARM: davinci: Don't rely on public mmc header to include leds.h
ARM: davinci: Don't rely on public mmc header to include interrupt.h
MIPS: Alchemy: Don't rely on public mmc header to include interrupt.h
mmc: core: First step in cleaning up public mmc header files
mmc: core: First step in cleaning up private mmc header files
mmc: core: Move public functions from core.h to private headers
mmc: core: Move some host specific public functions to host.h
mmc: core: Move erase/trim/discard defines from public core.h to mmc.h
mmc: core: Remove unused struct _mmc_csd from public mmc.h header
mmc: omap: Don't use mmc_card_present() when validating for inserted
card
mmc: vub300: Don't use mmc_card_present() when validating for inserted
card
mmc: core: Move public functions from card.h to private headers
mmc: core: Move public functions from host.h to private headers
mmc: core: Don't use extern declarations of public mmc functions

 arch/arm/mach-davinci/board-da850-evm.c     |   1 +
 arch/arm/mach-davinci/board-dm644x-evm.c    |   1 +
 arch/arm/mach-davinci/board-neuros-osd2.c   |   1 +
 arch/arm/mach-davinci/board-omapl138-hawk.c |   1 +
 arch/arm/mach-pxa/balloon3.c                |   1 +
 arch/arm/mach-pxa/colibri-pxa270-income.c   |   1 +
 arch/arm/mach-pxa/corgi.c                   |   1 +
 arch/arm/mach-pxa/trizeps4.c                |   1 +
 arch/arm/mach-pxa/vpac270.c                 |   1 +
 arch/arm/mach-pxa/zeus.c                    |   1 +
 arch/arm/mach-pxa/zylonite.c                |   1 +
 arch/mips/alchemy/devboards/db1300.c        |   1 +
 drivers/mmc/core/block.c                    |   6 +
 drivers/mmc/core/block.h                    |   8 +
 drivers/mmc/core/bus.c                      |   2 +
 drivers/mmc/core/bus.h                      |  16 +-
 drivers/mmc/core/card.h                     | 223 +++++++++++++++++++++++++
 drivers/mmc/core/core.c                     |   1 +
 drivers/mmc/core/core.h                     |  41 ++++-
 drivers/mmc/core/debugfs.c                  |   2 +
 drivers/mmc/core/host.h                     |  48 ++++++
 drivers/mmc/core/mmc.c                      |  13 ++
 drivers/mmc/core/mmc_ops.h                  |  14 ++
 drivers/mmc/core/mmc_test.c                 |   5 +
 drivers/mmc/core/pwrseq.h                   |   6 +-
 drivers/mmc/core/queue.c                    |   2 +
 drivers/mmc/core/queue.h                    |   6 +-
 drivers/mmc/core/quirks.c                   |   2 +
 drivers/mmc/core/sd.c                       |   2 +
 drivers/mmc/core/sd.h                       |   5 +-
 drivers/mmc/core/sd_ops.h                   |   9 ++
 drivers/mmc/core/sdio.c                     |   2 +
 drivers/mmc/core/sdio_bus.c                 |   1 +
 drivers/mmc/core/sdio_bus.h                 |   3 +
 drivers/mmc/core/sdio_cis.h                 |   3 +
 drivers/mmc/core/sdio_io.c                  |   2 +
 drivers/mmc/core/sdio_irq.c                 |   2 +
 drivers/mmc/core/sdio_ops.h                 |   5 +
 drivers/mmc/core/slot-gpio.h                |   2 +
 drivers/mmc/host/omap.c                     |   2 +-
 drivers/mmc/host/vub300.c                   |   6 +-
 include/linux/mmc/card.h                    | 242 ----------------------------
 include/linux/mmc/core.h                    |  86 ++--------
 include/linux/mmc/host.h                    |  63 ++------
 include/linux/mmc/mmc.h                     |  59 ++-----
 include/linux/mmc/slot-gpio.h               |   3 +
 46 files changed, 478 insertions(+), 426 deletions(-)
 create mode 100644 drivers/mmc/core/card.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Some of the pxa platforms, balloon3, colibri-pxa270-income, corgi, trizeps4, vpac270, zeus and zylonite depends on leds.h. Explicitly include it instead of relying on the public mmc header host.h.

Cc Daniel Mack <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Robert Jarzmik <[email protected]>

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

---
 arch/arm/mach-pxa/balloon3.c              | 1 +
 arch/arm/mach-pxa/colibri-pxa270-income.c | 1 +
 arch/arm/mach-pxa/corgi.c                 | 1 +
 arch/arm/mach-pxa/trizeps4.c              | 1 +
 arch/arm/mach-pxa/vpac270.c               | 1 +
 arch/arm/mach-pxa/zeus.c                  | 1 +
 arch/arm/mach-pxa/zylonite.c              | 1 +
 7 files changed, 7 insertions(+)
arch/arm/mach-pxa/balloon3.c +1 -0
index 8a3c409..d452a49 100644
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/leds.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
 #include <linux/fb.h>
arch/arm/mach-pxa/colibri-pxa270-income.c +1 -0
index 8cff770..d7cf47d 100644
@@ -17,6 +17,7 @@
 #include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/leds.h>
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
arch/arm/mach-pxa/corgi.c +1 -0
index 183cd34..7270f0d 100644
@@ -19,6 +19,7 @@
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
+#include <linux/leds.h>
 #include <linux/mmc/host.h>
 #include <linux/mtd/physmap.h>
 #include <linux/pm.h>
arch/arm/mach-pxa/trizeps4.c +1 -0
index ea78bc5..3dd13b4 100644
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/leds.h>
 #include <linux/export.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
arch/arm/mach-pxa/vpac270.c +1 -0
index c006ee9..70ab3ad 100644
@@ -15,6 +15,7 @@
 #include <linux/irq.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/leds.h>
 #include <linux/gpio.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/mtd/mtd.h>
arch/arm/mach-pxa/zeus.c +1 -0
index 3b94ecf..ecbcaee 100644
@@ -13,6 +13,7 @@
 
 #include <linux/cpufreq.h>
 #include <linux/interrupt.h>
+#include <linux/leds.h>
 #include <linux/irq.h>
 #include <linux/pm.h>
 #include <linux/gpio.h>
arch/arm/mach-pxa/zylonite.c +1 -0
index 3642389..4268552 100644
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
+#include <linux/leds.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
Signature · 1 line
1.9.1
maintainer
#2 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Quoted 9 lines · Ulf Hansson

Some of the pxa platforms, balloon3, colibri-pxa270-income, corgi, trizeps4, vpac270, zeus and zylonite depends on leds.h. Explicitly include it instead of relying on the public mmc header host.h.

Cc Daniel Mack <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Robert Jarzmik <[email protected]>
Quoted 4 lines

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

Actually I already have a patch for arch/arm/mach-pxa/idp.c which adds this include also in my -next tree, just in case you're tempted to modify this one, which would conflict with my pxa tree.

An other point, I checked which files don't have a leds.h :
- grep -ls _led arch/arm/mach-pxa/*.c > /tmp/a
- grep -ls 'linux/leds.h' arch/arm/mach-pxa/*.c > /tmp/b
- sdiff -s /tmp/a /tmp/b
This gives me :

	balloon3.c
	colibri-pxa270-income.c
	corgi.c
	corgi_pm.c
	em-x270.c
	ezx.c
	hx4700.c
	magician.c
	palmld.c
	palmtc.c
	palmtreo.c
	palmz72.c
	spitz_pm.c
	tosa.c
	trizeps4.c
	vpac270.c
	z2.c
	zeus.c
	zylonite.c
	zylonite_pxa300.c
	zylonite_pxa320.c

So I was wondering how you made the choice of which files you add the include to and which you don't touch ?

Cheers.

--
Robert

#3 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Quoted 48 lines · Robert Jarzmik
Quoted 9 lines · Ulf Hansson

Some of the pxa platforms, balloon3, colibri-pxa270-income, corgi, trizeps4, vpac270, zeus and zylonite depends on leds.h. Explicitly include it instead of relying on the public mmc header host.h.

Cc Daniel Mack <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Robert Jarzmik <[email protected]>
Quoted 4 lines

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

Actually I already have a patch for arch/arm/mach-pxa/idp.c which adds this include also in my -next tree, just in case you're tempted to modify this one, which would conflict with my pxa tree.

An other point, I checked which files don't have a leds.h :
- grep -ls _led arch/arm/mach-pxa/*.c > /tmp/a
- grep -ls 'linux/leds.h' arch/arm/mach-pxa/*.c > /tmp/b
- sdiff -s /tmp/a /tmp/b
This gives me :

        balloon3.c
        colibri-pxa270-income.c
        corgi.c
        corgi_pm.c
        em-x270.c
        ezx.c
        hx4700.c
        magician.c
        palmld.c
        palmtc.c
        palmtreo.c
        palmz72.c
        spitz_pm.c
        tosa.c
        trizeps4.c
        vpac270.c
        z2.c
        zeus.c
        zylonite.c
        zylonite_pxa300.c
        zylonite_pxa320.c
Quoted 2 lines

So I was wondering how you made the choice of which files you add the include to and which you don't touch ?

By building the pxa_defconfig, see what errors it reports and then fix them.

Isn't pxa_defconfig building all the variants?

Kind regards
Uffe

maintainer
#4 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Quoted 8 lines · Ulf Hansson
Quoted 3 lines · Robert Jarzmik

Ulf Hansson <[email protected]> writes:
So I was wondering how you made the choice of which files you add the include to and which you don't touch ?

By building the pxa_defconfig, see what errors it reports and then fix them.

Isn't pxa_defconfig building all the variants?

Euh actually it should, but it's not.

The file was built from all _existing_ pxa defconfigs in arch/arm/configs/. The trick is that there were many pxa boards for which no defconfig file was available, and therefore they "escape" the pxa_defconfig coverage.

Cheers.

Signature · 1 line
Robert
maintainer
#5 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Quoted 11 lines · Robert Jarzmik
Quoted 8 lines · Ulf Hansson
Quoted 3 lines · Robert Jarzmik

Ulf Hansson <[email protected]> writes:
So I was wondering how you made the choice of which files you add the include to and which you don't touch ?

By building the pxa_defconfig, see what errors it reports and then fix them.

Isn't pxa_defconfig building all the variants?

Euh actually it should, but it's not.

And actually thanks to a suggestion from Russell to improve my search line, I came up with the command line bellow, and perhaps you could fix the others with one command line and respin the patch ?

Here it is :

for f in $(grep -l _led arch/arm/mach-pxa/*.c | xargs grep -L linux/leds.h); do sed -i '0,/^#include <linux\/[l-m].*>$/{s/\(#include <linux\/[l-m].*\)/#include <linux\/leds.h>\n\1/}' $f; done

Cheers.

Signature · 1 line
Robert
#6 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Quoted 18 lines · Robert Jarzmik
Quoted 11 lines · Robert Jarzmik
Quoted 8 lines · Ulf Hansson
Quoted 3 lines · Robert Jarzmik

Ulf Hansson <[email protected]> writes:
So I was wondering how you made the choice of which files you add the include to and which you don't touch ?

By building the pxa_defconfig, see what errors it reports and then fix them.

Isn't pxa_defconfig building all the variants?

Euh actually it should, but it's not.

And actually thanks to a suggestion from Russell to improve my search line, I came up with the command line bellow, and perhaps you could fix the others with one command line and respin the patch ?

Quoted 7 lines

Here it is :

for f in $(grep -l _led arch/arm/mach-pxa/*.c | xargs grep -L linux/leds.h); do sed -i '0,/^#include <linux\/[l-m].*>$/{s/\(#include <linux\/[l-m].*\)/#include <linux\/leds.h>\n\1/}' $f; done

Cheers.

Robert, thanks for helping out!

While running the above command-line, the following files becomes changed:

arch/arm/mach-pxa/zylonite_pxa300.c
arch/arm/mach-pxa/zylonite_pxa320.c
arch/arm/mach-pxa/palmld.c
arch/arm/mach-pxa/palmtc.c
arch/arm/mach-pxa/ezx.c
arch/arm/mach-pxa/em-x270.c
arch/arm/mach-pxa/hx4700.c
arch/arm/mach-pxa/magician.c
arch/arm/mach-pxa/palmtreo.c
arch/arm/mach-pxa/corgi_pm.c
arch/arm/mach-pxa/spitz_pm.c
arch/arm/mach-pxa/tosa.c
arch/arm/mach-pxa/z2.c

However, already by building pxa_defconfig, I have verified that these files are being build successfully without any changes needed.

Because of that, I am not sure I would like to make any additional changes as a part of this series. I think it's easier if you later on deal with that as clean-ups via your pxa tree instead, does that make sense to you as well?

Kind regards
Uffe

maintainer
#7 lore raw

PATCH v3 1/15 ARM: pxa: Don't rely on public mmc header to include leds.h

Quoted 31 lines · Ulf Hansson
Quoted 18 lines · Robert Jarzmik
Quoted 11 lines · Robert Jarzmik
Quoted 8 lines · Ulf Hansson
Quoted 3 lines · Robert Jarzmik

Ulf Hansson <[email protected]> writes:
So I was wondering how you made the choice of which files you add the include to and which you don't touch ?

By building the pxa_defconfig, see what errors it reports and then fix them.

Isn't pxa_defconfig building all the variants?

Euh actually it should, but it's not.

And actually thanks to a suggestion from Russell to improve my search line, I came up with the command line bellow, and perhaps you could fix the others with one command line and respin the patch ?

Quoted 7 lines

Here it is :

for f in $(grep -l _led arch/arm/mach-pxa/*.c | xargs grep -L linux/leds.h); do sed -i '0,/^#include <linux\/[l-m].*>$/{s/\(#include <linux\/[l-m].*\)/#include <linux\/leds.h>\n\1/}' $f; done

Cheers.

Robert, thanks for helping out!

While running the above command-line, the following files becomes changed:

Quoted 13 lines

arch/arm/mach-pxa/zylonite_pxa300.c
arch/arm/mach-pxa/zylonite_pxa320.c
arch/arm/mach-pxa/palmld.c
arch/arm/mach-pxa/palmtc.c
arch/arm/mach-pxa/ezx.c
arch/arm/mach-pxa/em-x270.c
arch/arm/mach-pxa/hx4700.c
arch/arm/mach-pxa/magician.c
arch/arm/mach-pxa/palmtreo.c
arch/arm/mach-pxa/corgi_pm.c
arch/arm/mach-pxa/spitz_pm.c
arch/arm/mach-pxa/tosa.c
arch/arm/mach-pxa/z2.c

Indeed.

Quoted 2 lines

However, already by building pxa_defconfig, I have verified that these files are being build successfully without any changes needed.

Ha so for some (all ?) of them, another include is providing the leds.h, interesting. For many of them it is either :
- linux/power_supply.h
- linux/gpio_charger.h
- an mfd device (such as mfd/htc-pasic3.h)
- etc ...

Quoted 4 lines

Because of that, I am not sure I would like to make any additional changes as a part of this series. I think it's easier if you later on deal with that as clean-ups via your pxa tree instead, does that make sense to you as well?

Yeah as you wish, after all you're removing the leds.h and you'r patch addresses that, it's beyond its scope to fix all pxa boards which don't include leds.h properly.

Cheers.

Signature · 1 line
Robert
#8 lore raw

PATCH v3 2/15 ARM: davinci: Don't rely on public mmc header to include leds.h

In reply to Ulf Hansson

Some of the davinci boards, da850-evm, dm644x-evm and neuros-osd2 depends on leds.h. Explicitly include it instead of relying on the public mmc header host.h.

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

---
 arch/arm/mach-davinci/board-da850-evm.c   | 1 +
 arch/arm/mach-davinci/board-dm644x-evm.c  | 1 +
 arch/arm/mach-davinci/board-neuros-osd2.c | 1 +
 3 files changed, 3 insertions(+)
arch/arm/mach-davinci/board-da850-evm.c +1 -0
index aac3ab1..df3ca38 100644
@@ -18,6 +18,7 @@
 #include <linux/gpio/machine.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/leds.h>
 #include <linux/i2c.h>
 #include <linux/platform_data/at24.h>
 #include <linux/platform_data/pca953x.h>
arch/arm/mach-davinci/board-dm644x-evm.c +1 -0
index 521e4097..023480b 100644
@@ -25,6 +25,7 @@
 #include <linux/videodev2.h>
 #include <linux/v4l2-dv-timings.h>
 #include <linux/export.h>
+#include <linux/leds.h>
 
 #include <media/i2c/tvp514x.h>
 
arch/arm/mach-davinci/board-neuros-osd2.c +1 -0
index ad10017..0a78388 100644
@@ -25,6 +25,7 @@
  */
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/leds.h>
 #include <linux/mtd/partitions.h>
 #include <linux/platform_data/gpio-davinci.h>
 #include <linux/platform_data/i2c-davinci.h>
Signature · 1 line
1.9.1
#9 lore raw

PATCH v3 2/15 ARM: davinci: Don't rely on public mmc header to include leds.h

Quoted 8 lines · Ulf Hansson

Some of the davinci boards, da850-evm, dm644x-evm and neuros-osd2 depends on leds.h. Explicitly include it instead of relying on the public mmc header host.h.

Thanks,
Sekhar

#10 lore raw

PATCH v3 3/15 ARM: davinci: Don't rely on public mmc header to include interrupt.h

In reply to Ulf Hansson

The davinci board omapl138-hawk, depends on interrupt.h. Explicitly include it instead of relying on the public mmc header host.h.

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-davinci/board-omapl138-hawk.c +1 -0
index 41d5500..a3e7807 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/console.h>
+#include <linux/interrupt.h>
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/gpio-davinci.h>
Signature · 1 line
1.9.1
#11 lore raw

PATCH v3 3/15 ARM: davinci: Don't rely on public mmc header to include interrupt.h

Quoted 7 lines · Ulf Hansson

The davinci board omapl138-hawk, depends on interrupt.h. Explicitly include it instead of relying on the public mmc header host.h.

Additionally checked that 02/15 and 03/15 do not clash with anything I have queued so far. And built test my tree + these two patches with davinci_all_defconfig.

Thanks,
Sekhar

#12 lore raw

PATCH v3 4/15 MIPS: Alchemy: Don't rely on public mmc header to include interrupt.h

In reply to Ulf Hansson

The MIPS Alchemy db1300 dev board depends on interrupt.h. Explicitly include it instead of relying on the public mmc header host.h.

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

---
 arch/mips/alchemy/devboards/db1300.c | 1 +
 1 file changed, 1 insertion(+)
arch/mips/alchemy/devboards/db1300.c +1 -0
index d3c087f..a5504f5 100644
@@ -13,6 +13,7 @@
 #include <linux/i2c.h>
 #include <linux/io.h>
 #include <linux/leds.h>
+#include <linux/interrupt.h>
 #include <linux/ata_platform.h>
 #include <linux/mmc/host.h>
 #include <linux/module.h>
Signature · 1 line
1.9.1
Acked-by on v3 4/15
#13 lore raw

Re: [PATCH v3 04/15] MIPS: Alchemy: Don't rely on public mmc header to include interrupt.h

Quoted 10 lines · Ulf Hansson

The MIPS Alchemy db1300 dev board depends on interrupt.h. Explicitly include it instead of relying on the public mmc header host.h.

---

I am seeking an ack for this change as following changes for mmc in the series, has build-dependencies to it.

Ralf

#14 lore raw

PATCH v3 5/15 mmc: core: First step in cleaning up public mmc header files

In reply to Ulf Hansson

This is the first step in cleaning up the public mmc header files. In this change we makes sure each header file builds standalone, as that helps to resolve dependencies.

While changing this, it also seems reasonable to stop including other headers from inside a header itself which it don't depend upon. Additionally, in some cases such dependencies are better resolved by forward declaring the needed struct.

---
 include/linux/mmc/card.h      | 2 --
 include/linux/mmc/core.h      | 3 +--
 include/linux/mmc/host.h      | 9 ++-------
 include/linux/mmc/mmc.h       | 2 ++
 include/linux/mmc/slot-gpio.h | 3 +++
 5 files changed, 8 insertions(+), 11 deletions(-)
include/linux/mmc/card.h +0 -2
index 00449e5..ca64f5b 100644
@@ -11,7 +11,6 @@
 #define LINUX_MMC_CARD_H
 
 #include <linux/device.h>
-#include <linux/mmc/core.h>
 #include <linux/mod_devicetable.h>
 
 struct mmc_cid {
@@ -206,7 +205,6 @@ struct sdio_cis {
 };
 
 struct mmc_host;
-struct mmc_ios;
 struct sdio_func;
 struct sdio_func_tuple;
 
include/linux/mmc/core.h +1 -2
index e33cc74..64e2ddf 100644
@@ -8,10 +8,9 @@
 #ifndef LINUX_MMC_CORE_H
 #define LINUX_MMC_CORE_H
 
-#include <linux/interrupt.h>
 #include <linux/completion.h>
+#include <linux/types.h>
 
-struct request;
 struct mmc_data;
 struct mmc_request;
 
include/linux/mmc/host.h +2 -7
index 8bc8841..8d38c76 100644
@@ -10,16 +10,12 @@
 #ifndef LINUX_MMC_HOST_H
 #define LINUX_MMC_HOST_H
 
-#include <linux/leds.h>
-#include <linux/mutex.h>
-#include <linux/timer.h>
 #include <linux/sched.h>
 #include <linux/device.h>
 #include <linux/fault-inject.h>
 
 #include <linux/mmc/core.h>
 #include <linux/mmc/card.h>
-#include <linux/mmc/mmc.h>
 #include <linux/mmc/pm.h>
 
 struct mmc_ios {
@@ -82,6 +78,8 @@ struct mmc_ios {
 	bool enhanced_strobe;			/* hs400es selection */
 };
 
+struct mmc_host;
+
 struct mmc_host_ops {
 	/*
 	 * It is optional for the host to implement pre_req and post_req in
@@ -162,9 +160,6 @@ struct mmc_host_ops {
 				  unsigned int direction, int blk_size);
 };
 
-struct mmc_card;
-struct device;
-
 struct mmc_async_req {
 	/* active mmc request */
 	struct mmc_request	*mrq;
include/linux/mmc/mmc.h +2 -0
index a074082..261772e 100644
@@ -24,6 +24,8 @@
 #ifndef LINUX_MMC_MMC_H
 #define LINUX_MMC_MMC_H
 
+#include <linux/types.h>
+
 /* Standard MMC commands (4.1)           type  argument     response */
    /* class 1 */
 #define MMC_GO_IDLE_STATE         0   /* bc                          */
include/linux/mmc/slot-gpio.h +3 -0
index a7972cd..82f0d28 100644
@@ -11,6 +11,9 @@
 #ifndef MMC_SLOT_GPIO_H
 #define MMC_SLOT_GPIO_H
 
+#include <linux/types.h>
+#include <linux/irqreturn.h>
+
 struct mmc_host;
 
 int mmc_gpio_get_ro(struct mmc_host *host);
Signature · 1 line
1.9.1
Reviewed-by on v3 5/15
#15 lore raw

Re: [PATCH v3 05/15] mmc: core: First step in cleaning up public mmc header files

Quoted 9 lines · Ulf Hansson

This is the first step in cleaning up the public mmc header files. In this change we makes sure each header file builds standalone, as that helps to resolve dependencies.

While changing this, it also seems reasonable to stop including other headers from inside a header itself which it don't depend upon. Additionally, in some cases such dependencies are better resolved by forward declaring the needed struct.

Look nice,

Quoted 113 lines
---
 include/linux/mmc/card.h      | 2 --
 include/linux/mmc/core.h      | 3 +--
 include/linux/mmc/host.h      | 9 ++-------
 include/linux/mmc/mmc.h       | 2 ++
 include/linux/mmc/slot-gpio.h | 3 +++
 5 files changed, 8 insertions(+), 11 deletions(-)
include/linux/mmc/card.h +0 -2
index 00449e5..ca64f5b 100644
@@ -11,7 +11,6 @@
 #define LINUX_MMC_CARD_H
 
 #include <linux/device.h>
-#include <linux/mmc/core.h>
 #include <linux/mod_devicetable.h>
 
 struct mmc_cid {
@@ -206,7 +205,6 @@ struct sdio_cis {
 };
 
 struct mmc_host;
-struct mmc_ios;
 struct sdio_func;
 struct sdio_func_tuple;
 
include/linux/mmc/core.h +1 -2
index e33cc74..64e2ddf 100644
@@ -8,10 +8,9 @@
 #ifndef LINUX_MMC_CORE_H
 #define LINUX_MMC_CORE_H
 
-#include <linux/interrupt.h>
 #include <linux/completion.h>
+#include <linux/types.h>
 
-struct request;
 struct mmc_data;
 struct mmc_request;
 
include/linux/mmc/host.h +2 -7
index 8bc8841..8d38c76 100644
@@ -10,16 +10,12 @@
 #ifndef LINUX_MMC_HOST_H
 #define LINUX_MMC_HOST_H
 
-#include <linux/leds.h>
-#include <linux/mutex.h>
-#include <linux/timer.h>
 #include <linux/sched.h>
 #include <linux/device.h>
 #include <linux/fault-inject.h>
 
 #include <linux/mmc/core.h>
 #include <linux/mmc/card.h>
-#include <linux/mmc/mmc.h>
 #include <linux/mmc/pm.h>
 
 struct mmc_ios {
@@ -82,6 +78,8 @@ struct mmc_ios {
 	bool enhanced_strobe;			/* hs400es selection */
 };
 
+struct mmc_host;
+
 struct mmc_host_ops {
 	/*
 	 * It is optional for the host to implement pre_req and post_req in
@@ -162,9 +160,6 @@ struct mmc_host_ops {
 				  unsigned int direction, int blk_size);
 };
 
-struct mmc_card;
-struct device;
-
 struct mmc_async_req {
 	/* active mmc request */
 	struct mmc_request	*mrq;
include/linux/mmc/mmc.h +2 -0
index a074082..261772e 100644
@@ -24,6 +24,8 @@
 #ifndef LINUX_MMC_MMC_H
 #define LINUX_MMC_MMC_H
 
+#include <linux/types.h>
+
 /* Standard MMC commands (4.1)           type  argument     response */
    /* class 1 */
 #define MMC_GO_IDLE_STATE         0   /* bc                          */
include/linux/mmc/slot-gpio.h +3 -0
index a7972cd..82f0d28 100644
@@ -11,6 +11,9 @@
 #ifndef MMC_SLOT_GPIO_H
 #define MMC_SLOT_GPIO_H
 
+#include <linux/types.h>
+#include <linux/irqreturn.h>
+
 struct mmc_host;
 
 int mmc_gpio_get_ro(struct mmc_host *host);
Signature · 2 lines
Best Regards
Shawn Lin
#16 lore raw

PATCH v3 6/15 mmc: core: First step in cleaning up private mmc header files

In reply to Ulf Hansson

This is the first step in cleaning up the private mmc header files. In this change we makes sure each header file builds standalone, as that helps to resolve dependencies.

While changing this, it also seems reasonable to stop including other headers from inside a header itself which it don't depend upon. Additionally, in some cases such dependencies are better resolved by forward declaring the needed struct.

---
 drivers/mmc/core/block.h     | 8 ++++++++
 drivers/mmc/core/bus.h       | 4 ++++
 drivers/mmc/core/core.h      | 4 ++++
 drivers/mmc/core/host.h      | 3 ++-
 drivers/mmc/core/mmc_ops.h   | 5 +++++
 drivers/mmc/core/pwrseq.h    | 6 +++++-
 drivers/mmc/core/queue.h     | 6 +++++-
 drivers/mmc/core/sd.h        | 5 ++++-
 drivers/mmc/core/sd_ops.h    | 5 +++++
 drivers/mmc/core/sdio_bus.h  | 3 +++
 drivers/mmc/core/sdio_cis.h  | 3 +++
 drivers/mmc/core/sdio_ops.h  | 4 ++++
 drivers/mmc/core/slot-gpio.h | 2 ++
 13 files changed, 54 insertions(+), 4 deletions(-)
drivers/mmc/core/block.h +8 -0
index cdabb2e..00b7483 100644
@@ -1 +1,9 @@
+#ifndef _MMC_CORE_BLOCK_H
+#define _MMC_CORE_BLOCK_H
+
+struct mmc_queue;
+struct request;
+
 int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req);
+
+#endif
drivers/mmc/core/bus.h +4 -0
index 00a1971..93b516a 100644
@@ -11,6 +11,10 @@
 #ifndef _MMC_CORE_BUS_H
 #define _MMC_CORE_BUS_H
 
+struct mmc_host;
+struct mmc_card;
+struct device_type;
+
 #define MMC_DEV_ATTR(name, fmt, args...)					\
 static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf)	\
 {										\
drivers/mmc/core/core.h +4 -0
index 0fa86a2..29b91ae 100644
@@ -12,6 +12,10 @@
 #define _MMC_CORE_CORE_H
 
 #include <linux/delay.h>
+#include <linux/sched.h>
+
+struct mmc_host;
+struct mmc_card;
 
 #define MMC_CMD_RETRIES        3
 
drivers/mmc/core/host.h +2 -1
index 992bf53..366ce79 100644
@@ -10,7 +10,8 @@
  */
 #ifndef _MMC_CORE_HOST_H
 #define _MMC_CORE_HOST_H
-#include <linux/mmc/host.h>
+
+struct mmc_host;
 
 int mmc_register_host_class(void);
 void mmc_unregister_host_class(void);
drivers/mmc/core/mmc_ops.h +5 -0
index abd525e..e76365a 100644
@@ -12,6 +12,11 @@
 #ifndef _MMC_MMC_OPS_H
 #define _MMC_MMC_OPS_H
 
+#include <linux/types.h>
+
+struct mmc_host;
+struct mmc_card;
+
 int mmc_select_card(struct mmc_card *card);
 int mmc_deselect_cards(struct mmc_host *host);
 int mmc_set_dsr(struct mmc_host *host);
drivers/mmc/core/pwrseq.h +5 -1
index d69e751..39c911a 100644
@@ -8,7 +8,11 @@
 #ifndef _MMC_CORE_PWRSEQ_H
 #define _MMC_CORE_PWRSEQ_H
 
-#include <linux/mmc/host.h>
+#include <linux/types.h>
+
+struct mmc_host;
+struct device;
+struct module;
 
 struct mmc_pwrseq_ops {
 	void (*pre_power_on)(struct mmc_host *host);
drivers/mmc/core/queue.h +5 -1
index dac8c3d..0cea02a 100644
@@ -1,6 +1,11 @@
 #ifndef MMC_QUEUE_H
 #define MMC_QUEUE_H
 
+#include <linux/types.h>
+#include <linux/blkdev.h>
+#include <linux/mmc/core.h>
+#include <linux/mmc/host.h>
+
 static inline bool mmc_req_is_special(struct request *req)
 {
 	return req &&
@@ -9,7 +14,6 @@ static inline bool mmc_req_is_special(struct request *req)
 		 req_op(req) == REQ_OP_SECURE_ERASE);
 }
 
-struct request;
 struct task_struct;
 struct mmc_blk_data;
 
drivers/mmc/core/sd.h +4 -1
index aab824a..1ada980 100644
@@ -1,10 +1,13 @@
 #ifndef _MMC_CORE_SD_H
 #define _MMC_CORE_SD_H
 
-#include <linux/mmc/card.h>
+#include <linux/types.h>
 
 extern struct device_type sd_type;
 
+struct mmc_host;
+struct mmc_card;
+
 int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr);
 int mmc_sd_get_csd(struct mmc_host *host, struct mmc_card *card);
 void mmc_decode_cid(struct mmc_card *card);
drivers/mmc/core/sd_ops.h +5 -0
index ffc2305..ac7223c 100644
@@ -12,6 +12,11 @@
 #ifndef _MMC_SD_OPS_H
 #define _MMC_SD_OPS_H
 
+#include <linux/types.h>
+
+struct mmc_card;
+struct mmc_host;
+
 int mmc_app_set_bus_width(struct mmc_card *card, int width);
 int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
 int mmc_send_if_cond(struct mmc_host *host, u32 ocr);
drivers/mmc/core/sdio_bus.h +3 -0
index 567a768..b69a254 100644
@@ -11,6 +11,9 @@
 #ifndef _MMC_CORE_SDIO_BUS_H
 #define _MMC_CORE_SDIO_BUS_H
 
+struct mmc_card;
+struct sdio_func;
+
 struct sdio_func *sdio_alloc_func(struct mmc_card *card);
 int sdio_add_func(struct sdio_func *func);
 void sdio_remove_func(struct sdio_func *func);
drivers/mmc/core/sdio_cis.h +3 -0
index 4d903c2..16aa563 100644
@@ -14,6 +14,9 @@
 #ifndef _MMC_SDIO_CIS_H
 #define _MMC_SDIO_CIS_H
 
+struct mmc_card;
+struct sdio_func;
+
 int sdio_read_common_cis(struct mmc_card *card);
 void sdio_free_common_cis(struct mmc_card *card);
 
drivers/mmc/core/sdio_ops.h +4 -0
index 5660c7f..e1c36d6 100644
@@ -12,8 +12,12 @@
 #ifndef _MMC_SDIO_OPS_H
 #define _MMC_SDIO_OPS_H
 
+#include <linux/types.h>
 #include <linux/mmc/sdio.h>
 
+struct mmc_host;
+struct mmc_card;
+
 int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
 int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
 	unsigned addr, u8 in, u8* out);
drivers/mmc/core/slot-gpio.h +2 -0
index 8c1854d..a06fd84 100644
@@ -8,6 +8,8 @@
 #ifndef _MMC_CORE_SLOTGPIO_H
 #define _MMC_CORE_SLOTGPIO_H
 
+struct mmc_host;
+
 int mmc_gpio_alloc(struct mmc_host *host);
 
 #endif
Signature · 1 line
1.9.1
Reviewed-by on v3 6/15
#17 lore raw

Re: [PATCH v3 06/15] mmc: core: First step in cleaning up private mmc header files

Quoted 9 lines · Ulf Hansson

This is the first step in cleaning up the private mmc header files. In this change we makes sure each header file builds standalone, as that helps to resolve dependencies.

While changing this, it also seems reasonable to stop including other headers from inside a header itself which it don't depend upon. Additionally, in some cases such dependencies are better resolved by forward declaring the needed struct.

Quoted 226 lines
---
 drivers/mmc/core/block.h     | 8 ++++++++
 drivers/mmc/core/bus.h       | 4 ++++
 drivers/mmc/core/core.h      | 4 ++++
 drivers/mmc/core/host.h      | 3 ++-
 drivers/mmc/core/mmc_ops.h   | 5 +++++
 drivers/mmc/core/pwrseq.h    | 6 +++++-
 drivers/mmc/core/queue.h     | 6 +++++-
 drivers/mmc/core/sd.h        | 5 ++++-
 drivers/mmc/core/sd_ops.h    | 5 +++++
 drivers/mmc/core/sdio_bus.h  | 3 +++
 drivers/mmc/core/sdio_cis.h  | 3 +++
 drivers/mmc/core/sdio_ops.h  | 4 ++++
 drivers/mmc/core/slot-gpio.h | 2 ++
 13 files changed, 54 insertions(+), 4 deletions(-)
drivers/mmc/core/block.h +8 -0
index cdabb2e..00b7483 100644
@@ -1 +1,9 @@
+#ifndef _MMC_CORE_BLOCK_H
+#define _MMC_CORE_BLOCK_H
+
+struct mmc_queue;
+struct request;
+
 int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req);
+
+#endif
drivers/mmc/core/bus.h +4 -0
index 00a1971..93b516a 100644
@@ -11,6 +11,10 @@
 #ifndef _MMC_CORE_BUS_H
 #define _MMC_CORE_BUS_H
 
+struct mmc_host;
+struct mmc_card;
+struct device_type;
+
 #define MMC_DEV_ATTR(name, fmt, args...)					\
 static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf)	\
 {										\
drivers/mmc/core/core.h +4 -0
index 0fa86a2..29b91ae 100644
@@ -12,6 +12,10 @@
 #define _MMC_CORE_CORE_H
 
 #include <linux/delay.h>
+#include <linux/sched.h>
+
+struct mmc_host;
+struct mmc_card;
 
 #define MMC_CMD_RETRIES        3
 
drivers/mmc/core/host.h +2 -1
index 992bf53..366ce79 100644
@@ -10,7 +10,8 @@
  */
 #ifndef _MMC_CORE_HOST_H
 #define _MMC_CORE_HOST_H
-#include <linux/mmc/host.h>
+
+struct mmc_host;
 
 int mmc_register_host_class(void);
 void mmc_unregister_host_class(void);
drivers/mmc/core/mmc_ops.h +5 -0
index abd525e..e76365a 100644
@@ -12,6 +12,11 @@
 #ifndef _MMC_MMC_OPS_H
 #define _MMC_MMC_OPS_H
 
+#include <linux/types.h>
+
+struct mmc_host;
+struct mmc_card;
+
 int mmc_select_card(struct mmc_card *card);
 int mmc_deselect_cards(struct mmc_host *host);
 int mmc_set_dsr(struct mmc_host *host);
drivers/mmc/core/pwrseq.h +5 -1
index d69e751..39c911a 100644
@@ -8,7 +8,11 @@
 #ifndef _MMC_CORE_PWRSEQ_H
 #define _MMC_CORE_PWRSEQ_H
 
-#include <linux/mmc/host.h>
+#include <linux/types.h>
+
+struct mmc_host;
+struct device;
+struct module;
 
 struct mmc_pwrseq_ops {
 	void (*pre_power_on)(struct mmc_host *host);
drivers/mmc/core/queue.h +5 -1
index dac8c3d..0cea02a 100644
@@ -1,6 +1,11 @@
 #ifndef MMC_QUEUE_H
 #define MMC_QUEUE_H
 
+#include <linux/types.h>
+#include <linux/blkdev.h>
+#include <linux/mmc/core.h>
+#include <linux/mmc/host.h>
+
 static inline bool mmc_req_is_special(struct request *req)
 {
 	return req &&
@@ -9,7 +14,6 @@ static inline bool mmc_req_is_special(struct request *req)
 		 req_op(req) == REQ_OP_SECURE_ERASE);
 }
 
-struct request;
 struct task_struct;
 struct mmc_blk_data;
 
drivers/mmc/core/sd.h +4 -1
index aab824a..1ada980 100644
@@ -1,10 +1,13 @@
 #ifndef _MMC_CORE_SD_H
 #define _MMC_CORE_SD_H
 
-#include <linux/mmc/card.h>
+#include <linux/types.h>
 
 extern struct device_type sd_type;
 
+struct mmc_host;
+struct mmc_card;
+
 int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr);
 int mmc_sd_get_csd(struct mmc_host *host, struct mmc_card *card);
 void mmc_decode_cid(struct mmc_card *card);
drivers/mmc/core/sd_ops.h +5 -0
index ffc2305..ac7223c 100644
@@ -12,6 +12,11 @@
 #ifndef _MMC_SD_OPS_H
 #define _MMC_SD_OPS_H
 
+#include <linux/types.h>
+
+struct mmc_card;
+struct mmc_host;
+
 int mmc_app_set_bus_width(struct mmc_card *card, int width);
 int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
 int mmc_send_if_cond(struct mmc_host *host, u32 ocr);
drivers/mmc/core/sdio_bus.h +3 -0
index 567a768..b69a254 100644
@@ -11,6 +11,9 @@
 #ifndef _MMC_CORE_SDIO_BUS_H
 #define _MMC_CORE_SDIO_BUS_H
 
+struct mmc_card;
+struct sdio_func;
+
 struct sdio_func *sdio_alloc_func(struct mmc_card *card);
 int sdio_add_func(struct sdio_func *func);
 void sdio_remove_func(struct sdio_func *func);
drivers/mmc/core/sdio_cis.h +3 -0
index 4d903c2..16aa563 100644
@@ -14,6 +14,9 @@
 #ifndef _MMC_SDIO_CIS_H
 #define _MMC_SDIO_CIS_H
 
+struct mmc_card;
+struct sdio_func;
+
 int sdio_read_common_cis(struct mmc_card *card);
 void sdio_free_common_cis(struct mmc_card *card);
 
drivers/mmc/core/sdio_ops.h +4 -0
index 5660c7f..e1c36d6 100644
@@ -12,8 +12,12 @@
 #ifndef _MMC_SDIO_OPS_H
 #define _MMC_SDIO_OPS_H
 
+#include <linux/types.h>
 #include <linux/mmc/sdio.h>
 
+struct mmc_host;
+struct mmc_card;
+
 int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
 int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
 	unsigned addr, u8 in, u8* out);
drivers/mmc/core/slot-gpio.h +2 -0
index 8c1854d..a06fd84 100644
@@ -8,6 +8,8 @@
 #ifndef _MMC_CORE_SLOTGPIO_H
 #define _MMC_CORE_SLOTGPIO_H
 
+struct mmc_host;
+
 int mmc_gpio_alloc(struct mmc_host *host);
 
 #endif
Signature · 2 lines
Best Regards
Shawn Lin
#18 lore raw

PATCH v3 7/15 mmc: core: Move public functions from core.h to private headers

In reply to Ulf Hansson

A significant amount of functions are available through the public mmc core.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions to private mmc header files.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups, as an example some functions can be turned into static.

---
 drivers/mmc/core/block.c    |  3 +++
 drivers/mmc/core/core.h     | 37 ++++++++++++++++++++++++++++++++-
 drivers/mmc/core/mmc_ops.h  |  9 ++++++++
 drivers/mmc/core/mmc_test.c |  2 ++
 drivers/mmc/core/queue.c    |  1 +
 drivers/mmc/core/sd_ops.h   |  4 ++++
 drivers/mmc/core/sdio_io.c  |  1 +
 drivers/mmc/core/sdio_irq.c |  1 +
 drivers/mmc/core/sdio_ops.h |  1 +
 include/linux/mmc/core.h    | 50 ---------------------------------------------
 10 files changed, 58 insertions(+), 51 deletions(-)
drivers/mmc/core/block.c +3 -0
index 6adc3ce..41b5dbc 100644
@@ -47,6 +47,9 @@
 
 #include "queue.h"
 #include "block.h"
+#include "core.h"
+#include "mmc_ops.h"
+#include "sd_ops.h"
 
 MODULE_ALIAS("mmc:block");
 #ifdef MODULE_PARAM_PREFIX
drivers/mmc/core/core.h +36 -1
index 29b91ae..8a95c825 100644
@@ -16,6 +16,7 @@
 
 struct mmc_host;
 struct mmc_card;
+struct mmc_request;
 
 #define MMC_CMD_RETRIES        3
 
@@ -73,6 +74,7 @@ static inline void mmc_delay(unsigned int ms)
 void mmc_stop_host(struct mmc_host *host);
 
 int _mmc_detect_card_removed(struct mmc_host *host);
+int mmc_detect_card_removed(struct mmc_host *host);
 
 int mmc_attach_mmc(struct mmc_host *host);
 int mmc_attach_sd(struct mmc_host *host);
@@ -102,5 +104,38 @@ static inline void mmc_register_pm_notifier(struct mmc_host *host) { }
 static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { }
 #endif
 
-#endif
+void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq);
+bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
+
+int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
+		unsigned int arg);
+int mmc_can_erase(struct mmc_card *card);
+int mmc_can_trim(struct mmc_card *card);
+int mmc_can_discard(struct mmc_card *card);
+int mmc_can_sanitize(struct mmc_card *card);
+int mmc_can_secure_erase_trim(struct mmc_card *card);
+int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
+			unsigned int nr);
+unsigned int mmc_calc_max_discard(struct mmc_card *card);
+
+int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
+int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
+			bool is_rel_write);
+
+int __mmc_claim_host(struct mmc_host *host, atomic_t *abort);
+void mmc_release_host(struct mmc_host *host);
+void mmc_get_card(struct mmc_card *card);
+void mmc_put_card(struct mmc_card *card);
+
+/**
+ *	mmc_claim_host - exclusively claim a host
+ *	@host: mmc host to claim
+ *
+ *	Claim a host for a set of operations.
+ */
+static inline void mmc_claim_host(struct mmc_host *host)
+{
+	__mmc_claim_host(host, NULL);
+}
 
+#endif
drivers/mmc/core/mmc_ops.h +9 -0
index e76365a..74beea8 100644
@@ -31,12 +31,21 @@
 int mmc_spi_set_crc(struct mmc_host *host, int use_crc);
 int mmc_bus_test(struct mmc_card *card, u8 bus_width);
 int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status);
+int mmc_interrupt_hpi(struct mmc_card *card);
 int mmc_can_ext_csd(struct mmc_card *card);
+int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
 int mmc_switch_status(struct mmc_card *card);
 int __mmc_switch_status(struct mmc_card *card, bool crc_err_fatal);
 int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
 		unsigned int timeout_ms, unsigned char timing,
 		bool use_busy_signal, bool send_status,	bool retry_crc_err);
+int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
+		unsigned int timeout_ms);
+int mmc_stop_bkops(struct mmc_card *card);
+int mmc_read_bkops_status(struct mmc_card *card);
+void mmc_start_bkops(struct mmc_card *card, bool from_exception);
+int mmc_can_reset(struct mmc_card *card);
+int mmc_flush_cache(struct mmc_card *card);
 
 #endif
 
drivers/mmc/core/mmc_test.c +2 -0
index d350bd6..8075ad1 100644
@@ -22,6 +22,8 @@
 #include <linux/seq_file.h>
 #include <linux/module.h>
 
+#include "core.h"
+
 #define RESULT_OK		0
 #define RESULT_FAIL		1
 #define RESULT_UNSUP_HOST	2
drivers/mmc/core/queue.c +1 -0
index b198662..8f5bf5f8 100644
@@ -20,6 +20,7 @@
 
 #include "queue.h"
 #include "block.h"
+#include "core.h"
 
 #define MMC_QUEUE_BOUNCESZ	65536
 
drivers/mmc/core/sd_ops.h +4 -0
index ac7223c..784f8e6 100644
@@ -16,6 +16,7 @@
 
 struct mmc_card;
 struct mmc_host;
+struct mmc_command;
 
 int mmc_app_set_bus_width(struct mmc_card *card, int width);
 int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
@@ -25,6 +26,9 @@
 int mmc_sd_switch(struct mmc_card *card, int mode, int group,
 	u8 value, u8 *resp);
 int mmc_app_sd_status(struct mmc_card *card, void *ssr);
+int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
+int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card,
+	struct mmc_command *cmd, int retries);
 
 #endif
 
drivers/mmc/core/sdio_io.c +1 -0
index 406e5f0..76fe6d5 100644
@@ -16,6 +16,7 @@
 #include <linux/mmc/sdio_func.h>
 
 #include "sdio_ops.h"
+#include "core.h"
 
 /**
  *	sdio_claim_host - exclusively claim a bus for a certain SDIO function
drivers/mmc/core/sdio_irq.c +1 -0
index f1faf9a..d084635 100644
@@ -27,6 +27,7 @@
 #include <linux/mmc/sdio_func.h>
 
 #include "sdio_ops.h"
+#include "core.h"
 
 static int process_sdio_pending_irqs(struct mmc_host *host)
 {
drivers/mmc/core/sdio_ops.h +1 -0
index e1c36d6..bed8a83 100644
@@ -24,6 +24,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
 int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
 	unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz);
 int sdio_reset(struct mmc_host *host);
+unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz);
 
 static inline bool mmc_is_io_op(u32 opcode)
 {
include/linux/mmc/core.h +0 -50

71 lines not on this page · raw message

Signature · 1 line
1.9.1
Reviewed-by on v3 7/15
#19 lore raw

Re: [PATCH v3 07/15] mmc: core: Move public functions from core.h to private headers

Quoted 9 lines · Ulf Hansson

A significant amount of functions are available through the public mmc core.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions to private mmc header files.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups, as an example some functions can be turned into static.

[...]

drivers/mmc/core/sdio_io.c line 20

Quoted 6 lines
drivers/mmc/core/sdio_io.c +1 -0
@@ -16,6 +16,7 @@
 #include <linux/mmc/sdio_func.h>
 
 #include "sdio_ops.h"
+#include "core.h"
 

Should we need move it before sdio_ops.h to slightly keep the order? The same for sdio_orq.c change :)

Otherwise,

Quoted 104 lines
drivers/mmc/core/sdio_io.c +0 -0
 /**
  *	sdio_claim_host - exclusively claim a bus for a certain SDIO function
drivers/mmc/core/sdio_irq.c +1 -0
index f1faf9a..d084635 100644
@@ -27,6 +27,7 @@
 #include <linux/mmc/sdio_func.h>
 
 #include "sdio_ops.h"
+#include "core.h"
 
 static int process_sdio_pending_irqs(struct mmc_host *host)
 {
drivers/mmc/core/sdio_ops.h +1 -0
index e1c36d6..bed8a83 100644
@@ -24,6 +24,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
 int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
 	unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz);
 int sdio_reset(struct mmc_host *host);
+unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz);
 
 static inline bool mmc_is_io_op(u32 opcode)
 {
include/linux/mmc/core.h +0 -50
index 64e2ddf..e679a86 100644
@@ -158,25 +158,13 @@ struct mmc_request {
 struct mmc_card;
 struct mmc_async_req;
 
-extern int mmc_stop_bkops(struct mmc_card *);
-extern int mmc_read_bkops_status(struct mmc_card *);
 extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 					   struct mmc_async_req *,
 					   enum mmc_blk_status *);
-extern int mmc_interrupt_hpi(struct mmc_card *);
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
-extern void mmc_wait_for_req_done(struct mmc_host *host,
-				  struct mmc_request *mrq);
-extern bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
-extern int mmc_app_cmd(struct mmc_host *, struct mmc_card *);
-extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
-	struct mmc_command *, int);
-extern void mmc_start_bkops(struct mmc_card *card, bool from_exception);
-extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
 extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
 extern int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
-extern int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
 
 #define MMC_ERASE_ARG		0x00000000
 #define MMC_SECURE_ERASE_ARG	0x80000000
@@ -188,46 +176,8 @@ extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
 #define MMC_SECURE_ARGS		0x80000000
 #define MMC_TRIM_ARGS		0x00008001
 
-extern int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
-		     unsigned int arg);
-extern int mmc_can_erase(struct mmc_card *card);
-extern int mmc_can_trim(struct mmc_card *card);
-extern int mmc_can_discard(struct mmc_card *card);
-extern int mmc_can_sanitize(struct mmc_card *card);
-extern int mmc_can_secure_erase_trim(struct mmc_card *card);
-extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
-				   unsigned int nr);
-extern unsigned int mmc_calc_max_discard(struct mmc_card *card);
-
-extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
-extern int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
-			      bool is_rel_write);
 extern int mmc_hw_reset(struct mmc_host *host);
-extern int mmc_can_reset(struct mmc_card *card);
-
 extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
-extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
-
-extern int __mmc_claim_host(struct mmc_host *host, atomic_t *abort);
-extern void mmc_release_host(struct mmc_host *host);
-
-extern void mmc_get_card(struct mmc_card *card);
-extern void mmc_put_card(struct mmc_card *card);
-
-extern int mmc_flush_cache(struct mmc_card *);
-
-extern int mmc_detect_card_removed(struct mmc_host *host);
-
-/**
- *	mmc_claim_host - exclusively claim a host
- *	@host: mmc host to claim
- *
- *	Claim a host for a set of operations.
- */
-static inline void mmc_claim_host(struct mmc_host *host)
-{
-	__mmc_claim_host(host, NULL);
-}
 
 struct device_node;
 extern u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
Signature · 2 lines
Best Regards
Shawn Lin
#20 lore raw

Re: [PATCH v3 07/15] mmc: core: Move public functions from core.h to private headers

Quoted 17 lines · Shawn Lin
Quoted 10 lines · Ulf Hansson

A significant amount of functions are available through the public mmc core.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions to private mmc header files.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups, as an example some functions can be turned into static.

[...]

Quoted 3 lines
(quoted diff) +0 -0
@@ -16,6 +16,7 @@
 #include <linux/mmc/sdio_func.h>
 
Quoted 6 lines

drivers/mmc/core/sdio_io.c line 20

Quoted 3 lines
drivers/mmc/core/sdio_io.c +1 -0
 #include "sdio_ops.h"
+#include "core.h"
 

Should we need move it before sdio_ops.h to slightly keep the order? The same for sdio_orq.c change :)

One of the points in this series is also to fix header dependencies properly. In other words, each header must be able to build standalone. This removes any constraints on the order of how we include them. To test each header for this, I have some local Makefiles and c-files.

That said, I don't think there is an existing order we need or should maintain (unless because we think it looks nice). If that would be the case, it's should be considered as a bug.

[...]

Kind regards
Uffe

#21 lore raw

PATCH v3 8/15 mmc: core: Move some host specific public functions to host.h

In reply to Ulf Hansson

Ideally the public mmc header file, core.h, shouldn't contain interfaces particularly intended to be used by host drivers. Instead those should remain in the host.h header file. Therefore, let's move a couple functions from core.h to host.h.

---
 include/linux/mmc/core.h | 6 ------
 include/linux/mmc/host.h | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/mmc/core.h +0 -6
index e679a86..faacc90 100644
@@ -163,8 +163,6 @@ extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 					   enum mmc_blk_status *);
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
-extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
-extern int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
 
 #define MMC_ERASE_ARG		0x00000000
 #define MMC_SECURE_ERASE_ARG	0x80000000
@@ -179,8 +177,4 @@ extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 extern int mmc_hw_reset(struct mmc_host *host);
 extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
 
-struct device_node;
-extern u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
-extern int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
-
 #endif /* LINUX_MMC_CORE_H */
include/linux/mmc/host.h +6 -0
index 8d38c76..7de0519 100644
@@ -392,11 +392,14 @@ struct mmc_host {
 	unsigned long		private[0] ____cacheline_aligned;
 };
 
+struct device_node;
+
 struct mmc_host *mmc_alloc_host(int extra, struct device *);
 int mmc_add_host(struct mmc_host *);
 void mmc_remove_host(struct mmc_host *);
 void mmc_free_host(struct mmc_host *);
 int mmc_of_parse(struct mmc_host *host);
+int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
 
 static inline void *mmc_priv(struct mmc_host *host)
 {
@@ -452,6 +455,7 @@ static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc,
 }
 #endif
 
+u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
 int mmc_regulator_get_supply(struct mmc_host *mmc);
 
 static inline int mmc_card_is_removable(struct mmc_host *host)
@@ -538,6 +542,8 @@ static inline bool mmc_can_retune(struct mmc_host *host)
 	return host->can_retune == 1;
 }
 
+int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
+int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
 void mmc_retune_pause(struct mmc_host *host);
 void mmc_retune_unpause(struct mmc_host *host);
 
Signature · 1 line
1.9.1
Reviewed-by on v3 8/15
#22 lore raw

Re: [PATCH v3 08/15] mmc: core: Move some host specific public functions to host.h

Quoted 5 lines · Ulf Hansson

Ideally the public mmc header file, core.h, shouldn't contain interfaces particularly intended to be used by host drivers. Instead those should remain in the host.h header file. Therefore, let's move a couple functions from core.h to host.h.

Quoted 66 lines
---
 include/linux/mmc/core.h | 6 ------
 include/linux/mmc/host.h | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/mmc/core.h +0 -6
index e679a86..faacc90 100644
@@ -163,8 +163,6 @@ extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 					   enum mmc_blk_status *);
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
-extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
-extern int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
 
 #define MMC_ERASE_ARG		0x00000000
 #define MMC_SECURE_ERASE_ARG	0x80000000
@@ -179,8 +177,4 @@ extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 extern int mmc_hw_reset(struct mmc_host *host);
 extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
 
-struct device_node;
-extern u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
-extern int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
-
 #endif /* LINUX_MMC_CORE_H */
include/linux/mmc/host.h +6 -0
index 8d38c76..7de0519 100644
@@ -392,11 +392,14 @@ struct mmc_host {
 	unsigned long		private[0] ____cacheline_aligned;
 };
 
+struct device_node;
+
 struct mmc_host *mmc_alloc_host(int extra, struct device *);
 int mmc_add_host(struct mmc_host *);
 void mmc_remove_host(struct mmc_host *);
 void mmc_free_host(struct mmc_host *);
 int mmc_of_parse(struct mmc_host *host);
+int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
 
 static inline void *mmc_priv(struct mmc_host *host)
 {
@@ -452,6 +455,7 @@ static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc,
 }
 #endif
 
+u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
 int mmc_regulator_get_supply(struct mmc_host *mmc);
 
 static inline int mmc_card_is_removable(struct mmc_host *host)
@@ -538,6 +542,8 @@ static inline bool mmc_can_retune(struct mmc_host *host)
 	return host->can_retune == 1;
 }
 
+int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
+int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
 void mmc_retune_pause(struct mmc_host *host);
 void mmc_retune_unpause(struct mmc_host *host);
 
Signature · 2 lines
Best Regards
Shawn Lin
#23 lore raw

PATCH v3 9/15 mmc: core: Move erase/trim/discard defines from public core.h to mmc.h

In reply to Ulf Hansson

As the public mmc.h header already contains similar defines for other mmc commands and arguments, let's move those for erase/trim/discard into here as well.

---
 include/linux/mmc/core.h | 10 ----------
 include/linux/mmc/mmc.h  | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 11 deletions(-)
include/linux/mmc/core.h +0 -10
index faacc90..6440e10 100644
@@ -164,16 +164,6 @@ extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
 
-#define MMC_ERASE_ARG		0x00000000
-#define MMC_SECURE_ERASE_ARG	0x80000000
-#define MMC_TRIM_ARG		0x00000001
-#define MMC_DISCARD_ARG		0x00000003
-#define MMC_SECURE_TRIM1_ARG	0x80000001
-#define MMC_SECURE_TRIM2_ARG	0x80008000
-
-#define MMC_SECURE_ARGS		0x80000000
-#define MMC_TRIM_ARGS		0x00008001
-
 extern int mmc_hw_reset(struct mmc_host *host);
 extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
 
include/linux/mmc/mmc.h +12 -1
index 261772e..8f78543 100644
@@ -462,12 +462,23 @@ struct _mmc_csd {
 /*
  * MMC_SWITCH access modes
  */
-
 #define MMC_SWITCH_MODE_CMD_SET		0x00	/* Change the command set */
 #define MMC_SWITCH_MODE_SET_BITS	0x01	/* Set bits which are 1 in value */
 #define MMC_SWITCH_MODE_CLEAR_BITS	0x02	/* Clear bits which are 1 in value */
 #define MMC_SWITCH_MODE_WRITE_BYTE	0x03	/* Set target to value */
 
+/*
+ * Erase/trim/discard
+ */
+#define MMC_ERASE_ARG			0x00000000
+#define MMC_SECURE_ERASE_ARG		0x80000000
+#define MMC_TRIM_ARG			0x00000001
+#define MMC_DISCARD_ARG			0x00000003
+#define MMC_SECURE_TRIM1_ARG		0x80000001
+#define MMC_SECURE_TRIM2_ARG		0x80008000
+#define MMC_SECURE_ARGS			0x80000000
+#define MMC_TRIM_ARGS			0x00008001
+
 #define mmc_driver_type_mask(n)		(1 << (n))
 
 #endif /* LINUX_MMC_MMC_H */
Signature · 1 line
1.9.1
Reviewed-by on v3 9/15
#24 lore raw

Re: [PATCH v3 09/15] mmc: core: Move erase/trim/discard defines from public core.h to mmc.h

Quoted 37 lines · Ulf Hansson

As the public mmc.h header already contains similar defines for other mmc commands and arguments, let's move those for erase/trim/discard into here as well.

---
 include/linux/mmc/core.h | 10 ----------
 include/linux/mmc/mmc.h  | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 11 deletions(-)
include/linux/mmc/core.h +0 -10
index faacc90..6440e10 100644
@@ -164,16 +164,6 @@ extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
 
-#define MMC_ERASE_ARG		0x00000000
-#define MMC_SECURE_ERASE_ARG	0x80000000
-#define MMC_TRIM_ARG		0x00000001
-#define MMC_DISCARD_ARG		0x00000003
-#define MMC_SECURE_TRIM1_ARG	0x80000001
-#define MMC_SECURE_TRIM2_ARG	0x80008000
-
-#define MMC_SECURE_ARGS		0x80000000
-#define MMC_TRIM_ARGS		0x00008001
-
 extern int mmc_hw_reset(struct mmc_host *host);
 extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
 
include/linux/mmc/mmc.h +0 -0
index 261772e..8f78543 100644

include/linux/mmc/mmc.h struct _mmc_csd { · line 465

Quoted 4 lines
include/linux/mmc/mmc.h +0 -1
@@ -462,12 +462,23 @@ struct _mmc_csd {
 /*
  * MMC_SWITCH access modes
  */
-

It's not relevant to remove this blank line?

Otherwise,

Quoted 21 lines
include/linux/mmc/mmc.h +12 -0
 #define MMC_SWITCH_MODE_CMD_SET		0x00	/* Change the command set */
 #define MMC_SWITCH_MODE_SET_BITS	0x01	/* Set bits which are 1 in value */
 #define MMC_SWITCH_MODE_CLEAR_BITS	0x02	/* Clear bits which are 1 in value */
 #define MMC_SWITCH_MODE_WRITE_BYTE	0x03	/* Set target to value */
 
+/*
+ * Erase/trim/discard
+ */
+#define MMC_ERASE_ARG			0x00000000
+#define MMC_SECURE_ERASE_ARG		0x80000000
+#define MMC_TRIM_ARG			0x00000001
+#define MMC_DISCARD_ARG			0x00000003
+#define MMC_SECURE_TRIM1_ARG		0x80000001
+#define MMC_SECURE_TRIM2_ARG		0x80008000
+#define MMC_SECURE_ARGS			0x80000000
+#define MMC_TRIM_ARGS			0x00008001
+
 #define mmc_driver_type_mask(n)		(1 << (n))
 
 #endif /* LINUX_MMC_MMC_H */
Signature · 2 lines
Best Regards
Shawn Lin
#25 lore raw

Re: [PATCH v3 09/15] mmc: core: Move erase/trim/discard defines from public core.h to mmc.h

Quoted 37 lines · Shawn Lin
Quoted 36 lines · Ulf Hansson

As the public mmc.h header already contains similar defines for other mmc commands and arguments, let's move those for erase/trim/discard into here as well.

---
 include/linux/mmc/core.h | 10 ----------
 include/linux/mmc/mmc.h  | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 11 deletions(-)
include/linux/mmc/core.h +0 -10
index faacc90..6440e10 100644
@@ -164,16 +164,6 @@ extern struct mmc_async_req *mmc_start_req(struct
 mmc_host *,
 extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *,
 int);
 
-#define MMC_ERASE_ARG          0x00000000
-#define MMC_SECURE_ERASE_ARG   0x80000000
-#define MMC_TRIM_ARG           0x00000001
-#define MMC_DISCARD_ARG                0x00000003
-#define MMC_SECURE_TRIM1_ARG   0x80000001
-#define MMC_SECURE_TRIM2_ARG   0x80008000
-
-#define MMC_SECURE_ARGS                0x80000000
-#define MMC_TRIM_ARGS          0x00008001
-
 extern int mmc_hw_reset(struct mmc_host *host);

extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card
*);

Quoted 12 lines

include/linux/mmc/mmc.h struct _mmc_csd { · line 465

Quoted 9 lines
include/linux/mmc/mmc.h +0 -1
index 261772e..8f78543 100644
@@ -462,12 +462,23 @@ struct _mmc_csd {
 /*
  * MMC_SWITCH access modes
  */
-

It's not relevant to remove this blank line?

Well, as I am anyway doing "clean-ups" I thought it make sense to fold it in here. Seems a bit too much for a separate patch for that.

Quoted 27 lines

Otherwise,

Quoted 22 lines
include/linux/mmc/mmc.h +0 -0
 #define MMC_SWITCH_MODE_CMD_SET                0x00    /* Change the

command set */
#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in
value */
#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1
in value */
#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */

include/linux/mmc/mmc.h +12 -0
+/*
+ * Erase/trim/discard
+ */
+#define MMC_ERASE_ARG                  0x00000000
+#define MMC_SECURE_ERASE_ARG           0x80000000
+#define MMC_TRIM_ARG                   0x00000001
+#define MMC_DISCARD_ARG                        0x00000003
+#define MMC_SECURE_TRIM1_ARG           0x80000001
+#define MMC_SECURE_TRIM2_ARG           0x80008000
+#define MMC_SECURE_ARGS                        0x80000000
+#define MMC_TRIM_ARGS                  0x00008001
+
 #define mmc_driver_type_mask(n)                (1 << (n))
Quoted 8 lines
Quoted 2 lines

#endif /* LINUX_MMC_MMC_H */

--
Best Regards
Shawn Lin

Kind regards
Uffe

#26 lore raw

PATCH v3 10/15 mmc: core: Remove unused struct _mmc_csd from public mmc.h header

In reply to Ulf Hansson
---
 include/linux/mmc/mmc.h | 44 --------------------------------------------
 1 file changed, 44 deletions(-)
include/linux/mmc/mmc.h +0 -44
index 8f78543..7406d9b 100644
@@ -184,50 +184,6 @@ static inline bool mmc_op_multi(u32 opcode)
 #define R2_SPI_OUT_OF_RANGE	(1 << 15)	/* or CSD overwrite */
 #define R2_SPI_CSD_OVERWRITE	R2_SPI_OUT_OF_RANGE
 
-/* These are unpacked versions of the actual responses */
-
-struct _mmc_csd {
-	u8  csd_structure;
-	u8  spec_vers;
-	u8  taac;
-	u8  nsac;
-	u8  tran_speed;
-	u16 ccc;
-	u8  read_bl_len;
-	u8  read_bl_partial;
-	u8  write_blk_misalign;
-	u8  read_blk_misalign;
-	u8  dsr_imp;
-	u16 c_size;
-	u8  vdd_r_curr_min;
-	u8  vdd_r_curr_max;
-	u8  vdd_w_curr_min;
-	u8  vdd_w_curr_max;
-	u8  c_size_mult;
-	union {
-		struct { /* MMC system specification version 3.1 */
-			u8  erase_grp_size;
-			u8  erase_grp_mult;
-		} v31;
-		struct { /* MMC system specification version 2.2 */
-			u8  sector_size;
-			u8  erase_grp_size;
-		} v22;
-	} erase;
-	u8  wp_grp_size;
-	u8  wp_grp_enable;
-	u8  default_ecc;
-	u8  r2w_factor;
-	u8  write_bl_len;
-	u8  write_bl_partial;
-	u8  file_format_grp;
-	u8  copy;
-	u8  perm_write_protect;
-	u8  tmp_write_protect;
-	u8  file_format;
-	u8  ecc;
-};
-
 /*
  * OCR bits are mostly in host.h
  */
Signature · 1 line
1.9.1
Reviewed-by on v3 10/15
#27 lore raw

Re: [PATCH v3 10/15] mmc: core: Remove unused struct _mmc_csd from public mmc.h header

Quoted 6 lines · Ulf Hansson
---
 include/linux/mmc/mmc.h | 44 --------------------------------------------
 1 file changed, 44 deletions(-)

Looks quite strightforward, but it will be better if adding a commit msg body here. Anyway,

Quoted 56 lines
include/linux/mmc/mmc.h +0 -44
index 8f78543..7406d9b 100644
@@ -184,50 +184,6 @@ static inline bool mmc_op_multi(u32 opcode)
 #define R2_SPI_OUT_OF_RANGE	(1 << 15)	/* or CSD overwrite */
 #define R2_SPI_CSD_OVERWRITE	R2_SPI_OUT_OF_RANGE
 
-/* These are unpacked versions of the actual responses */
-
-struct _mmc_csd {
-	u8  csd_structure;
-	u8  spec_vers;
-	u8  taac;
-	u8  nsac;
-	u8  tran_speed;
-	u16 ccc;
-	u8  read_bl_len;
-	u8  read_bl_partial;
-	u8  write_blk_misalign;
-	u8  read_blk_misalign;
-	u8  dsr_imp;
-	u16 c_size;
-	u8  vdd_r_curr_min;
-	u8  vdd_r_curr_max;
-	u8  vdd_w_curr_min;
-	u8  vdd_w_curr_max;
-	u8  c_size_mult;
-	union {
-		struct { /* MMC system specification version 3.1 */
-			u8  erase_grp_size;
-			u8  erase_grp_mult;
-		} v31;
-		struct { /* MMC system specification version 2.2 */
-			u8  sector_size;
-			u8  erase_grp_size;
-		} v22;
-	} erase;
-	u8  wp_grp_size;
-	u8  wp_grp_enable;
-	u8  default_ecc;
-	u8  r2w_factor;
-	u8  write_bl_len;
-	u8  write_bl_partial;
-	u8  file_format_grp;
-	u8  copy;
-	u8  perm_write_protect;
-	u8  tmp_write_protect;
-	u8  file_format;
-	u8  ecc;
-};
-
 /*
  * OCR bits are mostly in host.h
  */
Signature · 2 lines
Best Regards
Shawn Lin
#28 lore raw

Re: [PATCH v3 10/15] mmc: core: Remove unused struct _mmc_csd from public mmc.h header

Quoted 11 lines · Shawn Lin
Quoted 7 lines · Ulf Hansson
---
 include/linux/mmc/mmc.h | 44 --------------------------------------------
 1 file changed, 44 deletions(-)

Looks quite strightforward, but it will be better if adding a commit msg body here. Anyway,

I didn't know what to put there besides what is already said in the header. :-)

Anyway, I try to elaborate a bit and add something.

[...]

Kind regards
Uffe

#29 lore raw

PATCH v3 11/15 mmc: omap: Don't use mmc_card_present() when validating for inserted card

In reply to Ulf Hansson

The mmc_card_present() function helps the mmc core to track an internal state of the card device. More importantly, it's not intended to be used by mmc host drivers to check for an inserted card. Therefore, let's stop using it and instead rely on checking for a valid pointer to a struct mmc_card, as it should be good enough.

---
 drivers/mmc/host/omap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/omap.c +1 -1
index be3c49f..bd49f34 100644
@@ -893,7 +893,7 @@ static void mmc_omap_cover_handler(unsigned long param)
 	 * If no card is inserted, we postpone polling until
 	 * the cover has been closed.
 	 */
-	if (slot->mmc->card == NULL || !mmc_card_present(slot->mmc->card))
+	if (slot->mmc->card == NULL)
 		return;
 
 	mod_timer(&slot->cover_timer,
Signature · 1 line
1.9.1
#30 lore raw

PATCH v3 12/15 mmc: vub300: Don't use mmc_card_present() when validating for inserted card

In reply to Ulf Hansson

The mmc_card_present() function helps the mmc core to track an internal state of the card device. More importantly, it's not intended to be used by mmc host drivers to check for an inserted card. Therefore, let's stop using it and instead rely on checking for a valid pointer to a struct mmc_card, as it should be good enough.

---
 drivers/mmc/host/vub300.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/vub300.c +2 -4
index 21ea776..c061e7c 100644
@@ -726,8 +726,7 @@ static void vub300_deadwork_thread(struct work_struct *work)
 		 */
 	} else if (vub300->card_present) {
 		check_vub300_port_status(vub300);
-	} else if (vub300->mmc && vub300->mmc->card &&
-		   mmc_card_present(vub300->mmc->card)) {
+	} else if (vub300->mmc && vub300->mmc->card) {
 		/*
 		 * the MMC core must not have responded
 		 * to the previous indication - lets
@@ -1754,8 +1753,7 @@ static void vub300_cmndwork_thread(struct work_struct *work)
 		int data_length;
 		mutex_lock(&vub300->cmd_mutex);
 		init_completion(&vub300->command_complete);
-		if (likely(vub300->vub_name[0]) || !vub300->mmc->card ||
-		    !mmc_card_present(vub300->mmc->card)) {
+		if (likely(vub300->vub_name[0]) || !vub300->mmc->card) {
 			/*
 			 * the name of the EMPTY Pseudo firmware file
 			 * is used as a flag to indicate that the file
Signature · 1 line
1.9.1
#31 lore raw

PATCH v3 13/15 mmc: core: Move public functions from card.h to private headers

In reply to Ulf Hansson

A significant amount of functions and other definitions are available through the public mmc card.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions/definitions to private mmc header files.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups.

---
 drivers/mmc/core/block.c    |   2 +
 drivers/mmc/core/bus.c      |   1 +
 drivers/mmc/core/bus.h      |  14 ++-
 drivers/mmc/core/card.h     | 223 ++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/core/core.c     |   1 +
 drivers/mmc/core/debugfs.c  |   1 +
 drivers/mmc/core/mmc.c      |  13 +++
 drivers/mmc/core/mmc_test.c |   2 +
 drivers/mmc/core/queue.c    |   1 +
 drivers/mmc/core/quirks.c   |   2 +
 drivers/mmc/core/sd.c       |   1 +
 drivers/mmc/core/sdio.c     |   1 +
 drivers/mmc/core/sdio_bus.c |   1 +
 drivers/mmc/core/sdio_io.c  |   1 +
 drivers/mmc/core/sdio_irq.c |   1 +
 include/linux/mmc/card.h    | 240 --------------------------------------------
 16 files changed, 263 insertions(+), 242 deletions(-)
 create mode 100644 drivers/mmc/core/card.h
drivers/mmc/core/block.c +2 -0
index 41b5dbc..a8300be 100644
@@ -48,6 +48,8 @@
 #include "queue.h"
 #include "block.h"
 #include "core.h"
+#include "card.h"
+#include "bus.h"
 #include "mmc_ops.h"
 #include "sd_ops.h"
 
drivers/mmc/core/bus.c +1 -0
index c64266f..3be2e6a 100644
@@ -23,6 +23,7 @@
 #include <linux/mmc/host.h>
 
 #include "core.h"
+#include "card.h"
 #include "sdio_cis.h"
 #include "bus.h"
 
drivers/mmc/core/bus.h +12 -2
index 93b516a..72b0ef0 100644
@@ -11,9 +11,10 @@
 #ifndef _MMC_CORE_BUS_H
 #define _MMC_CORE_BUS_H
 
+#include <linux/device.h>
+
 struct mmc_host;
 struct mmc_card;
-struct device_type;
 
 #define MMC_DEV_ATTR(name, fmt, args...)					\
 static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf)	\
@@ -31,5 +32,14 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host,
 int mmc_register_bus(void);
 void mmc_unregister_bus(void);
 
-#endif
+struct mmc_driver {
+	struct device_driver drv;
+	int (*probe)(struct mmc_card *card);
+	void (*remove)(struct mmc_card *card);
+	void (*shutdown)(struct mmc_card *card);
+};
 
+int mmc_register_driver(struct mmc_driver *drv);
+void mmc_unregister_driver(struct mmc_driver *drv);
+
+#endif
drivers/mmc/core/card.h new file +223 -0

223 lines not on this page · raw message

drivers/mmc/core/core.c +1 -0
index 3b34a75..8c45825 100644
@@ -40,6 +40,7 @@
 #include <trace/events/mmc.h>
 
 #include "core.h"
+#include "card.h"
 #include "bus.h"
 #include "host.h"
 #include "sdio_bus.h"
drivers/mmc/core/debugfs.c +1 -0
index 30623b8..2843e6a 100644
@@ -20,6 +20,7 @@
 #include <linux/mmc/host.h>
 
 #include "core.h"
+#include "card.h"
 #include "mmc_ops.h"
 
 #ifdef CONFIG_FAIL_MMC_REQUEST
drivers/mmc/core/mmc.c +13 -0
index ec2e85c..b91abe0 100644
@@ -21,6 +21,7 @@
 #include <linux/mmc/mmc.h>
 
 #include "core.h"
+#include "card.h"
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
@@ -307,6 +308,18 @@ static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd)
 	}
 }
 
+static void mmc_part_add(struct mmc_card *card, unsigned int size,
+			 unsigned int part_cfg, char *name, int idx, bool ro,
+			 int area_type)
+{
+	card->part[card->nr_parts].size = size;
+	card->part[card->nr_parts].part_cfg = part_cfg;
+	sprintf(card->part[card->nr_parts].name, name, idx);
+	card->part[card->nr_parts].force_ro = ro;
+	card->part[card->nr_parts].area_type = area_type;
+	card->nr_parts++;
+}
+
 static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd)
 {
 	int idx;
drivers/mmc/core/mmc_test.c +2 -0
index 8075ad1..8dd2115 100644
@@ -23,6 +23,8 @@
 #include <linux/module.h>
 
 #include "core.h"
+#include "card.h"
+#include "bus.h"
 
 #define RESULT_OK		0
 #define RESULT_FAIL		1
drivers/mmc/core/queue.c +1 -0
index 8f5bf5f8..611f5c6 100644
@@ -21,6 +21,7 @@
 #include "queue.h"
 #include "block.h"
 #include "core.h"
+#include "card.h"
 
 #define MMC_QUEUE_BOUNCESZ	65536
 
drivers/mmc/core/quirks.c +2 -0
index ca9cade..bf25a9c 100644
@@ -15,6 +15,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_ids.h>
 
+#include "card.h"
+
 #ifndef SDIO_VENDOR_ID_TI
 #define SDIO_VENDOR_ID_TI		0x0097
 #endif
drivers/mmc/core/sd.c +1 -0
index a614f37..d66b08d 100644
@@ -22,6 +22,7 @@
 #include <linux/mmc/sd.h>
 
 #include "core.h"
+#include "card.h"
 #include "bus.h"
 #include "mmc_ops.h"
 #include "sd.h"
drivers/mmc/core/sdio.c +1 -0
index 6810b3a..5419c0d 100644
@@ -20,6 +20,7 @@
 #include <linux/mmc/sdio_ids.h>
 
 #include "core.h"
+#include "card.h"
 #include "bus.h"
 #include "sd.h"
 #include "sdio_bus.h"
drivers/mmc/core/sdio_bus.c +1 -0
index 86f5b32..e992a7f 100644
@@ -25,6 +25,7 @@
 #include <linux/of.h>
 
 #include "core.h"
+#include "card.h"
 #include "sdio_cis.h"
 #include "sdio_bus.h"
 
drivers/mmc/core/sdio_io.c +1 -0
index 76fe6d5..74195d7 100644
@@ -17,6 +17,7 @@
 
 #include "sdio_ops.h"
 #include "core.h"
+#include "card.h"
 
 /**
  *	sdio_claim_host - exclusively claim a bus for a certain SDIO function
drivers/mmc/core/sdio_irq.c +1 -0
index d084635..d29faf2 100644
@@ -28,6 +28,7 @@
 
 #include "sdio_ops.h"
 #include "core.h"
+#include "card.h"
 
 static int process_sdio_pending_irqs(struct mmc_host *host)
 {
include/linux/mmc/card.h +0 -240

265 lines not on this page · raw message

Signature · 1 line
1.9.1
Reviewed-by on v3 13/15
#32 lore raw

Re: [PATCH v3 13/15] mmc: core: Move public functions from card.h to private headers

Quoted 7 lines · Ulf Hansson

A significant amount of functions and other definitions are available through the public mmc card.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions/definitions to private mmc header files.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups.

Looks good,

Quoted 735 lines
---
 drivers/mmc/core/block.c    |   2 +
 drivers/mmc/core/bus.c      |   1 +
 drivers/mmc/core/bus.h      |  14 ++-
 drivers/mmc/core/card.h     | 223 ++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/core/core.c     |   1 +
 drivers/mmc/core/debugfs.c  |   1 +
 drivers/mmc/core/mmc.c      |  13 +++
 drivers/mmc/core/mmc_test.c |   2 +
 drivers/mmc/core/queue.c    |   1 +
 drivers/mmc/core/quirks.c   |   2 +
 drivers/mmc/core/sd.c       |   1 +
 drivers/mmc/core/sdio.c     |   1 +
 drivers/mmc/core/sdio_bus.c |   1 +
 drivers/mmc/core/sdio_io.c  |   1 +
 drivers/mmc/core/sdio_irq.c |   1 +
 include/linux/mmc/card.h    | 240 --------------------------------------------
 16 files changed, 263 insertions(+), 242 deletions(-)
 create mode 100644 drivers/mmc/core/card.h
drivers/mmc/core/block.c +2 -0
index 41b5dbc..a8300be 100644
@@ -48,6 +48,8 @@
 #include "queue.h"
 #include "block.h"
 #include "core.h"
+#include "card.h"
+#include "bus.h"
 #include "mmc_ops.h"
 #include "sd_ops.h"
 
drivers/mmc/core/bus.c +1 -0
index c64266f..3be2e6a 100644
@@ -23,6 +23,7 @@
 #include <linux/mmc/host.h>
 
 #include "core.h"
+#include "card.h"
 #include "sdio_cis.h"
 #include "bus.h"
 
drivers/mmc/core/bus.h +12 -2
index 93b516a..72b0ef0 100644
@@ -11,9 +11,10 @@
 #ifndef _MMC_CORE_BUS_H
 #define _MMC_CORE_BUS_H
 
+#include <linux/device.h>
+
 struct mmc_host;
 struct mmc_card;
-struct device_type;
 
 #define MMC_DEV_ATTR(name, fmt, args...)					\
 static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf)	\
@@ -31,5 +32,14 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host,
 int mmc_register_bus(void);
 void mmc_unregister_bus(void);
 
-#endif
+struct mmc_driver {
+	struct device_driver drv;
+	int (*probe)(struct mmc_card *card);
+	void (*remove)(struct mmc_card *card);
+	void (*shutdown)(struct mmc_card *card);
+};
 
+int mmc_register_driver(struct mmc_driver *drv);
+void mmc_unregister_driver(struct mmc_driver *drv);
+
+#endif
drivers/mmc/core/card.h new file +223 -0
new file mode 100644
index 0000000..95e8fc5
@@ -0,0 +1,223 @@
+/*
+ * Private header for the mmc subsystem
+ *
+ * Copyright (C) 2016 Linaro Ltd
+ *
+ * Author: Ulf Hansson <[email protected]>
+ *
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#ifndef _MMC_CORE_CARD_H
+#define _MMC_CORE_CARD_H
+
+#include <linux/mmc/card.h>
+
+#define mmc_card_name(c)	((c)->cid.prod_name)
+#define mmc_card_id(c)		(dev_name(&(c)->dev))
+#define mmc_dev_to_card(d)	container_of(d, struct mmc_card, dev)
+
+/* Card states */
+#define MMC_STATE_PRESENT	(1<<0)		/* present in sysfs */
+#define MMC_STATE_READONLY	(1<<1)		/* card is read-only */
+#define MMC_STATE_BLOCKADDR	(1<<2)		/* card uses block-addressing */
+#define MMC_CARD_SDXC		(1<<3)		/* card is SDXC */
+#define MMC_CARD_REMOVED	(1<<4)		/* card has been removed */
+#define MMC_STATE_DOING_BKOPS	(1<<5)		/* card is doing BKOPS */
+#define MMC_STATE_SUSPENDED	(1<<6)		/* card is suspended */
+
+#define mmc_card_present(c)	((c)->state & MMC_STATE_PRESENT)
+#define mmc_card_readonly(c)	((c)->state & MMC_STATE_READONLY)
+#define mmc_card_blockaddr(c)	((c)->state & MMC_STATE_BLOCKADDR)
+#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
+#define mmc_card_removed(c)	((c) && ((c)->state & MMC_CARD_REMOVED))
+#define mmc_card_doing_bkops(c)	((c)->state & MMC_STATE_DOING_BKOPS)
+#define mmc_card_suspended(c)	((c)->state & MMC_STATE_SUSPENDED)
+
+#define mmc_card_set_present(c)	((c)->state |= MMC_STATE_PRESENT)
+#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
+#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
+#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
+#define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
+#define mmc_card_set_doing_bkops(c)	((c)->state |= MMC_STATE_DOING_BKOPS)
+#define mmc_card_clr_doing_bkops(c)	((c)->state &= ~MMC_STATE_DOING_BKOPS)
+#define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED)
+#define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED)
+
+/*
+ * The world is not perfect and supplies us with broken mmc/sdio devices.
+ * For at least some of these bugs we need a work-around.
+ */
+struct mmc_fixup {
+	/* CID-specific fields. */
+	const char *name;
+
+	/* Valid revision range */
+	u64 rev_start, rev_end;
+
+	unsigned int manfid;
+	unsigned short oemid;
+
+	/* SDIO-specific fields. You can use SDIO_ANY_ID here of course */
+	u16 cis_vendor, cis_device;
+
+	/* for MMC cards */
+	unsigned int ext_csd_rev;
+
+	void (*vendor_fixup)(struct mmc_card *card, int data);
+	int data;
+};
+
+#define CID_MANFID_ANY (-1u)
+#define CID_OEMID_ANY ((unsigned short) -1)
+#define CID_NAME_ANY (NULL)
+
+#define EXT_CSD_REV_ANY (-1u)
+
+#define CID_MANFID_SANDISK      0x2
+#define CID_MANFID_TOSHIBA      0x11
+#define CID_MANFID_MICRON       0x13
+#define CID_MANFID_SAMSUNG      0x15
+#define CID_MANFID_KINGSTON     0x70
+#define CID_MANFID_HYNIX	0x90
+
+#define END_FIXUP { NULL }
+
+#define _FIXUP_EXT(_name, _manfid, _oemid, _rev_start, _rev_end,	\
+		   _cis_vendor, _cis_device,				\
+		   _fixup, _data, _ext_csd_rev)				\
+	{						\
+		.name = (_name),			\
+		.manfid = (_manfid),			\
+		.oemid = (_oemid),			\
+		.rev_start = (_rev_start),		\
+		.rev_end = (_rev_end),			\
+		.cis_vendor = (_cis_vendor),		\
+		.cis_device = (_cis_device),		\
+		.vendor_fixup = (_fixup),		\
+		.data = (_data),			\
+		.ext_csd_rev = (_ext_csd_rev),		\
+	}
+
+#define MMC_FIXUP_REV(_name, _manfid, _oemid, _rev_start, _rev_end,	\
+		      _fixup, _data, _ext_csd_rev)			\
+	_FIXUP_EXT(_name, _manfid,					\
+		   _oemid, _rev_start, _rev_end,			\
+		   SDIO_ANY_ID, SDIO_ANY_ID,				\
+		   _fixup, _data, _ext_csd_rev)				\
+
+#define MMC_FIXUP(_name, _manfid, _oemid, _fixup, _data) \
+	MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data,	\
+		      EXT_CSD_REV_ANY)
+
+#define MMC_FIXUP_EXT_CSD_REV(_name, _manfid, _oemid, _fixup, _data,	\
+			      _ext_csd_rev)				\
+	MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data,	\
+		      _ext_csd_rev)
+
+#define SDIO_FIXUP(_vendor, _device, _fixup, _data)			\
+	_FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY,			\
+		    CID_OEMID_ANY, 0, -1ull,				\
+		   _vendor, _device,					\
+		   _fixup, _data, EXT_CSD_REV_ANY)			\
+
+#define cid_rev(hwrev, fwrev, year, month)	\
+	(((u64) hwrev) << 40 |			\
+	 ((u64) fwrev) << 32 |			\
+	 ((u64) year) << 16 |			\
+	 ((u64) month))
+
+#define cid_rev_card(card)			\
+	cid_rev(card->cid.hwrev,		\
+		    card->cid.fwrev,		\
+		    card->cid.year,		\
+		    card->cid.month)
+
+/*
+ * Unconditionally quirk add/remove.
+ */
+static inline void __maybe_unused add_quirk(struct mmc_card *card, int data)
+{
+	card->quirks |= data;
+}
+
+static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)
+{
+	card->quirks &= ~data;
+}
+
+/*
+ * Quirk add/remove for MMC products.
+ */
+static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data)
+{
+	if (mmc_card_mmc(card))
+		card->quirks |= data;
+}
+
+static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card,
+						   int data)
+{
+	if (mmc_card_mmc(card))
+		card->quirks &= ~data;
+}
+
+/*
+ * Quirk add/remove for SD products.
+ */
+static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data)
+{
+	if (mmc_card_sd(card))
+		card->quirks |= data;
+}
+
+static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card,
+						   int data)
+{
+	if (mmc_card_sd(card))
+		card->quirks &= ~data;
+}
+
+static inline int mmc_card_lenient_fn0(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_LENIENT_FN0;
+}
+
+static inline int mmc_blksz_for_byte_mode(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
+}
+
+static inline int mmc_card_disable_cd(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_DISABLE_CD;
+}
+
+static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF;
+}
+
+static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512;
+}
+
+static inline int mmc_card_long_read_time(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_LONG_READ_TIME;
+}
+
+static inline int mmc_card_broken_irq_polling(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_BROKEN_IRQ_POLLING;
+}
+
+static inline int mmc_card_broken_hpi(const struct mmc_card *c)
+{
+	return c->quirks & MMC_QUIRK_BROKEN_HPI;
+}
+
+void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table);
+
+#endif
drivers/mmc/core/core.c +1 -0
index 3b34a75..8c45825 100644
@@ -40,6 +40,7 @@
 #include <trace/events/mmc.h>
 
 #include "core.h"
+#include "card.h"
 #include "bus.h"
 #include "host.h"
 #include "sdio_bus.h"
drivers/mmc/core/debugfs.c +1 -0
index 30623b8..2843e6a 100644
@@ -20,6 +20,7 @@
 #include <linux/mmc/host.h>
 
 #include "core.h"
+#include "card.h"
 #include "mmc_ops.h"
 
 #ifdef CONFIG_FAIL_MMC_REQUEST
drivers/mmc/core/mmc.c +13 -0
index ec2e85c..b91abe0 100644
@@ -21,6 +21,7 @@
 #include <linux/mmc/mmc.h>
 
 #include "core.h"
+#include "card.h"
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
@@ -307,6 +308,18 @@ static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd)
 	}
 }
 
+static void mmc_part_add(struct mmc_card *card, unsigned int size,
+			 unsigned int part_cfg, char *name, int idx, bool ro,
+			 int area_type)
+{
+	card->part[card->nr_parts].size = size;
+	card->part[card->nr_parts].part_cfg = part_cfg;
+	sprintf(card->part[card->nr_parts].name, name, idx);
+	card->part[card->nr_parts].force_ro = ro;
+	card->part[card->nr_parts].area_type = area_type;
+	card->nr_parts++;
+}
+
 static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd)
 {
 	int idx;
drivers/mmc/core/mmc_test.c +2 -0
index 8075ad1..8dd2115 100644
@@ -23,6 +23,8 @@
 #include <linux/module.h>
 
 #include "core.h"
+#include "card.h"
+#include "bus.h"
 
 #define RESULT_OK		0
 #define RESULT_FAIL		1
drivers/mmc/core/queue.c +1 -0
index 8f5bf5f8..611f5c6 100644
@@ -21,6 +21,7 @@
 #include "queue.h"
 #include "block.h"
 #include "core.h"
+#include "card.h"
 
 #define MMC_QUEUE_BOUNCESZ	65536
 
drivers/mmc/core/quirks.c +2 -0
index ca9cade..bf25a9c 100644
@@ -15,6 +15,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_ids.h>
 
+#include "card.h"
+
 #ifndef SDIO_VENDOR_ID_TI
 #define SDIO_VENDOR_ID_TI		0x0097
 #endif
drivers/mmc/core/sd.c +1 -0
index a614f37..d66b08d 100644
@@ -22,6 +22,7 @@
 #include <linux/mmc/sd.h>
 
 #include "core.h"
+#include "card.h"
 #include "bus.h"
 #include "mmc_ops.h"
 #include "sd.h"
drivers/mmc/core/sdio.c +1 -0
index 6810b3a..5419c0d 100644
@@ -20,6 +20,7 @@
 #include <linux/mmc/sdio_ids.h>
 
 #include "core.h"
+#include "card.h"
 #include "bus.h"
 #include "sd.h"
 #include "sdio_bus.h"
drivers/mmc/core/sdio_bus.c +1 -0
index 86f5b32..e992a7f 100644
@@ -25,6 +25,7 @@
 #include <linux/of.h>
 
 #include "core.h"
+#include "card.h"
 #include "sdio_cis.h"
 #include "sdio_bus.h"
 
drivers/mmc/core/sdio_io.c +1 -0
index 76fe6d5..74195d7 100644
@@ -17,6 +17,7 @@
 
 #include "sdio_ops.h"
 #include "core.h"
+#include "card.h"
 
 /**
  *	sdio_claim_host - exclusively claim a bus for a certain SDIO function
drivers/mmc/core/sdio_irq.c +1 -0
index d084635..d29faf2 100644
@@ -28,6 +28,7 @@
 
 #include "sdio_ops.h"
 #include "core.h"
+#include "card.h"
 
 static int process_sdio_pending_irqs(struct mmc_host *host)
 {
include/linux/mmc/card.h +0 -240
index ca64f5b..29d00c9 100644
@@ -248,13 +248,6 @@ struct mmc_card {
 #define MMC_TYPE_SDIO		2		/* SDIO card */
 #define MMC_TYPE_SD_COMBO	3		/* SD combo (IO+mem) card */
 	unsigned int		state;		/* (our) card state */
-#define MMC_STATE_PRESENT	(1<<0)		/* present in sysfs */
-#define MMC_STATE_READONLY	(1<<1)		/* card is read-only */
-#define MMC_STATE_BLOCKADDR	(1<<2)		/* card uses block-addressing */
-#define MMC_CARD_SDXC		(1<<3)		/* card is SDXC */
-#define MMC_CARD_REMOVED	(1<<4)		/* card has been removed */
-#define MMC_STATE_DOING_BKOPS	(1<<5)		/* card is doing BKOPS */
-#define MMC_STATE_SUSPENDED	(1<<6)		/* card is suspended */
 	unsigned int		quirks; 	/* card quirks */
 #define MMC_QUIRK_LENIENT_FN0	(1<<0)		/* allow SDIO FN0 writes outside of the VS CCCR range */
 #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1)	/* use func->cur_blksize */
@@ -273,7 +266,6 @@ struct mmc_card {
 #define MMC_QUIRK_TRIM_BROKEN	(1<<12)		/* Skip trim */
 #define MMC_QUIRK_BROKEN_HPI	(1<<13)		/* Disable broken HPI support */
 
-
 	unsigned int		erase_size;	/* erase size in sectors */
  	unsigned int		erase_shift;	/* if erase unit is power 2 */
  	unsigned int		pref_erase;	/* in sectors */
@@ -309,245 +301,13 @@ struct mmc_card {
 	unsigned int    nr_parts;
 };
 
-/*
- * This function fill contents in mmc_part.
- */
-static inline void mmc_part_add(struct mmc_card *card, unsigned int size,
-			unsigned int part_cfg, char *name, int idx, bool ro,
-			int area_type)
-{
-	card->part[card->nr_parts].size = size;
-	card->part[card->nr_parts].part_cfg = part_cfg;
-	sprintf(card->part[card->nr_parts].name, name, idx);
-	card->part[card->nr_parts].force_ro = ro;
-	card->part[card->nr_parts].area_type = area_type;
-	card->nr_parts++;
-}
-
 static inline bool mmc_large_sector(struct mmc_card *card)
 {
 	return card->ext_csd.data_sector_size == 4096;
 }
 
-/*
- *  The world is not perfect and supplies us with broken mmc/sdio devices.
- *  For at least some of these bugs we need a work-around.
- */
-
-struct mmc_fixup {
-	/* CID-specific fields. */
-	const char *name;
-
-	/* Valid revision range */
-	u64 rev_start, rev_end;
-
-	unsigned int manfid;
-	unsigned short oemid;
-
-	/* SDIO-specfic fields. You can use SDIO_ANY_ID here of course */
-	u16 cis_vendor, cis_device;
-
-	/* for MMC cards */
-	unsigned int ext_csd_rev;
-
-	void (*vendor_fixup)(struct mmc_card *card, int data);
-	int data;
-};
-
-#define CID_MANFID_ANY (-1u)
-#define CID_OEMID_ANY ((unsigned short) -1)
-#define CID_NAME_ANY (NULL)
-
-#define EXT_CSD_REV_ANY (-1u)
-
-#define CID_MANFID_SANDISK      0x2
-#define CID_MANFID_TOSHIBA      0x11
-#define CID_MANFID_MICRON       0x13
-#define CID_MANFID_SAMSUNG      0x15
-#define CID_MANFID_KINGSTON     0x70
-#define CID_MANFID_HYNIX	0x90
-
-#define END_FIXUP { NULL }
-
-#define _FIXUP_EXT(_name, _manfid, _oemid, _rev_start, _rev_end,	\
-		   _cis_vendor, _cis_device,				\
-		   _fixup, _data, _ext_csd_rev)				\
-	{						   \
-		.name = (_name),			   \
-		.manfid = (_manfid),			   \
-		.oemid = (_oemid),			   \
-		.rev_start = (_rev_start),		   \
-		.rev_end = (_rev_end),			   \
-		.cis_vendor = (_cis_vendor),		   \
-		.cis_device = (_cis_device),		   \
-		.vendor_fixup = (_fixup),		   \
-		.data = (_data),			   \
-		.ext_csd_rev = (_ext_csd_rev),		   \
-	 }
-
-#define MMC_FIXUP_REV(_name, _manfid, _oemid, _rev_start, _rev_end,	\
-		      _fixup, _data, _ext_csd_rev)			\
-	_FIXUP_EXT(_name, _manfid,					\
-		   _oemid, _rev_start, _rev_end,			\
-		   SDIO_ANY_ID, SDIO_ANY_ID,				\
-		   _fixup, _data, _ext_csd_rev)				\
-
-#define MMC_FIXUP(_name, _manfid, _oemid, _fixup, _data) \
-	MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data,	\
-		      EXT_CSD_REV_ANY)
-
-#define MMC_FIXUP_EXT_CSD_REV(_name, _manfid, _oemid, _fixup, _data,	\
-			      _ext_csd_rev)				\
-	MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data,	\
-		      _ext_csd_rev)
-
-#define SDIO_FIXUP(_vendor, _device, _fixup, _data)			\
-	_FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY,			\
-		    CID_OEMID_ANY, 0, -1ull,				\
-		   _vendor, _device,					\
-		   _fixup, _data, EXT_CSD_REV_ANY)			\
-
-#define cid_rev(hwrev, fwrev, year, month)	\
-	(((u64) hwrev) << 40 |                  \
-	 ((u64) fwrev) << 32 |                  \
-	 ((u64) year) << 16 |                   \
-	 ((u64) month))
-
-#define cid_rev_card(card)		  \
-	cid_rev(card->cid.hwrev,	  \
-		    card->cid.fwrev,      \
-		    card->cid.year,	  \
-		    card->cid.month)
-
-/*
- * Unconditionally quirk add/remove.
- */
-
-static inline void __maybe_unused add_quirk(struct mmc_card *card, int data)
-{
-	card->quirks |= data;
-}
-
-static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)
-{
-	card->quirks &= ~data;
-}
-
 #define mmc_card_mmc(c)		((c)->type == MMC_TYPE_MMC)
 #define mmc_card_sd(c)		((c)->type == MMC_TYPE_SD)
 #define mmc_card_sdio(c)	((c)->type == MMC_TYPE_SDIO)
 
-#define mmc_card_present(c)	((c)->state & MMC_STATE_PRESENT)
-#define mmc_card_readonly(c)	((c)->state & MMC_STATE_READONLY)
-#define mmc_card_blockaddr(c)	((c)->state & MMC_STATE_BLOCKADDR)
-#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
-#define mmc_card_removed(c)	((c) && ((c)->state & MMC_CARD_REMOVED))
-#define mmc_card_doing_bkops(c)	((c)->state & MMC_STATE_DOING_BKOPS)
-#define mmc_card_suspended(c)	((c)->state & MMC_STATE_SUSPENDED)
-
-#define mmc_card_set_present(c)	((c)->state |= MMC_STATE_PRESENT)
-#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
-#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
-#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
-#define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
-#define mmc_card_set_doing_bkops(c)	((c)->state |= MMC_STATE_DOING_BKOPS)
-#define mmc_card_clr_doing_bkops(c)	((c)->state &= ~MMC_STATE_DOING_BKOPS)
-#define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED)
-#define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED)
-
-/*
- * Quirk add/remove for MMC products.
- */
-
-static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data)
-{
-	if (mmc_card_mmc(card))
-		card->quirks |= data;
-}
-
-static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card,
-						   int data)
-{
-	if (mmc_card_mmc(card))
-		card->quirks &= ~data;
-}
-
-/*
- * Quirk add/remove for SD products.
- */
-
-static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data)
-{
-	if (mmc_card_sd(card))
-		card->quirks |= data;
-}
-
-static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card,
-						   int data)
-{
-	if (mmc_card_sd(card))
-		card->quirks &= ~data;
-}
-
-static inline int mmc_card_lenient_fn0(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_LENIENT_FN0;
-}
-
-static inline int mmc_blksz_for_byte_mode(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
-}
-
-static inline int mmc_card_disable_cd(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_DISABLE_CD;
-}
-
-static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF;
-}
-
-static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512;
-}
-
-static inline int mmc_card_long_read_time(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_LONG_READ_TIME;
-}
-
-static inline int mmc_card_broken_irq_polling(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_BROKEN_IRQ_POLLING;
-}
-
-static inline int mmc_card_broken_hpi(const struct mmc_card *c)
-{
-	return c->quirks & MMC_QUIRK_BROKEN_HPI;
-}
-
-#define mmc_card_name(c)	((c)->cid.prod_name)
-#define mmc_card_id(c)		(dev_name(&(c)->dev))
-
-#define mmc_dev_to_card(d)	container_of(d, struct mmc_card, dev)
-
-/*
- * MMC device driver (e.g., Flash card, I/O card...)
- */
-struct mmc_driver {
-	struct device_driver drv;
-	int (*probe)(struct mmc_card *);
-	void (*remove)(struct mmc_card *);
-	void (*shutdown)(struct mmc_card *);
-};
-
-extern int mmc_register_driver(struct mmc_driver *);
-extern void mmc_unregister_driver(struct mmc_driver *);
-
-extern void mmc_fixup_device(struct mmc_card *card,
-			     const struct mmc_fixup *table);
-
 #endif /* LINUX_MMC_CARD_H */
Signature · 2 lines
Best Regards
Shawn Lin
#33 lore raw

PATCH v3 14/15 mmc: core: Move public functions from host.h to private headers

In reply to Ulf Hansson

A significant amount of functions are available through the public mmc host.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions to private mmc host.h header file.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups.

---
 drivers/mmc/core/block.c    |  1 +
 drivers/mmc/core/bus.c      |  1 +
 drivers/mmc/core/debugfs.c  |  1 +
 drivers/mmc/core/host.h     | 49 ++++++++++++++++++++++++++++++++++++++++++++-
 drivers/mmc/core/mmc_test.c |  1 +
 drivers/mmc/core/sd.c       |  1 +
 drivers/mmc/core/sdio.c     |  1 +
 include/linux/mmc/host.h    | 48 ++------------------------------------------
 8 files changed, 56 insertions(+), 47 deletions(-)
drivers/mmc/core/block.c +1 -0
index a8300be..7bd0338 100644
@@ -49,6 +49,7 @@
 #include "block.h"
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
 #include "sd_ops.h"
drivers/mmc/core/bus.c +1 -0
index 3be2e6a..3012465 100644
@@ -24,6 +24,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "sdio_cis.h"
 #include "bus.h"
 
drivers/mmc/core/debugfs.c +1 -0
index 2843e6a..a1fba57 100644
@@ -21,6 +21,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "mmc_ops.h"
 
 #ifdef CONFIG_FAIL_MMC_REQUEST
drivers/mmc/core/host.h +48 -1

61 lines not on this page · raw message

drivers/mmc/core/mmc_test.c +1 -0
index 8dd2115..83d193c 100644
@@ -24,6 +24,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 
 #define RESULT_OK		0
drivers/mmc/core/sd.c +1 -0
index d66b08d..8b4f139 100644
@@ -23,6 +23,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
 #include "sd.h"
drivers/mmc/core/sdio.c +1 -0
index 5419c0d..261c886 100644
@@ -21,6 +21,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 #include "sd.h"
 #include "sdio_bus.h"
include/linux/mmc/host.h +2 -46

77 lines not on this page · raw message

Signature · 1 line
1.9.1
Reviewed-by on v3 14/15
#34 lore raw

Re: [PATCH v3 14/15] mmc: core: Move public functions from host.h to private headers

Quoted 8 lines · Ulf Hansson

A significant amount of functions are available through the public mmc host.h header file. Let's slim down this public mmc interface, as to prevent users from abusing it, by moving some of the functions to private mmc host.h header file.

This change concentrates on moving the functions into private mmc headers, following changes may continue with additional clean-ups.

The same comment for the order of header files, anyway

Quoted 237 lines
---
 drivers/mmc/core/block.c    |  1 +
 drivers/mmc/core/bus.c      |  1 +
 drivers/mmc/core/debugfs.c  |  1 +
 drivers/mmc/core/host.h     | 49 ++++++++++++++++++++++++++++++++++++++++++++-
 drivers/mmc/core/mmc_test.c |  1 +
 drivers/mmc/core/sd.c       |  1 +
 drivers/mmc/core/sdio.c     |  1 +
 include/linux/mmc/host.h    | 48 ++------------------------------------------
 8 files changed, 56 insertions(+), 47 deletions(-)
drivers/mmc/core/block.c +1 -0
index a8300be..7bd0338 100644
@@ -49,6 +49,7 @@
 #include "block.h"
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
 #include "sd_ops.h"
drivers/mmc/core/bus.c +1 -0
index 3be2e6a..3012465 100644
@@ -24,6 +24,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "sdio_cis.h"
 #include "bus.h"
 
drivers/mmc/core/debugfs.c +1 -0
index 2843e6a..a1fba57 100644
@@ -21,6 +21,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "mmc_ops.h"
 
 #ifdef CONFIG_FAIL_MMC_REQUEST
drivers/mmc/core/host.h +48 -1
index 366ce79..fb6a76a 100644
@@ -11,7 +11,7 @@
 #ifndef _MMC_CORE_HOST_H
 #define _MMC_CORE_HOST_H
 
-struct mmc_host;
+#include <linux/mmc/host.h>
 
 int mmc_register_host_class(void);
 void mmc_unregister_host_class(void);
@@ -21,6 +21,53 @@
 void mmc_retune_hold(struct mmc_host *host);
 void mmc_retune_release(struct mmc_host *host);
 int mmc_retune(struct mmc_host *host);
+void mmc_retune_pause(struct mmc_host *host);
+void mmc_retune_unpause(struct mmc_host *host);
+
+static inline void mmc_retune_recheck(struct mmc_host *host)
+{
+	if (host->hold_retune <= 1)
+		host->retune_now = 1;
+}
+
+static inline int mmc_host_cmd23(struct mmc_host *host)
+{
+	return host->caps & MMC_CAP_CMD23;
+}
+
+static inline int mmc_boot_partition_access(struct mmc_host *host)
+{
+	return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
+}
+
+static inline int mmc_host_uhs(struct mmc_host *host)
+{
+	return host->caps &
+		(MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
+		 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
+		 MMC_CAP_UHS_DDR50);
+}
+
+static inline bool mmc_card_hs200(struct mmc_card *card)
+{
+	return card->host->ios.timing == MMC_TIMING_MMC_HS200;
+}
+
+static inline bool mmc_card_ddr52(struct mmc_card *card)
+{
+	return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
+}
+
+static inline bool mmc_card_hs400(struct mmc_card *card)
+{
+	return card->host->ios.timing == MMC_TIMING_MMC_HS400;
+}
+
+static inline bool mmc_card_hs400es(struct mmc_card *card)
+{
+	return card->host->ios.enhanced_strobe;
+}
+
 
 #endif
 
drivers/mmc/core/mmc_test.c +1 -0
index 8dd2115..83d193c 100644
@@ -24,6 +24,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 
 #define RESULT_OK		0
drivers/mmc/core/sd.c +1 -0
index d66b08d..8b4f139 100644
@@ -23,6 +23,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
 #include "sd.h"
drivers/mmc/core/sdio.c +1 -0
index 5419c0d..261c886 100644
@@ -21,6 +21,7 @@
 
 #include "core.h"
 #include "card.h"
+#include "host.h"
 #include "bus.h"
 #include "sd.h"
 #include "sdio_bus.h"
include/linux/mmc/host.h +2 -46
index 7de0519..97699d5 100644
@@ -473,56 +473,20 @@ static inline int mmc_card_wake_sdio_irq(struct mmc_host *host)
 	return host->pm_flags & MMC_PM_WAKE_SDIO_IRQ;
 }
 
-static inline int mmc_host_cmd23(struct mmc_host *host)
-{
-	return host->caps & MMC_CAP_CMD23;
-}
-
-static inline int mmc_boot_partition_access(struct mmc_host *host)
-{
-	return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
-}
-
-static inline int mmc_host_uhs(struct mmc_host *host)
-{
-	return host->caps &
-		(MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
-		 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
-		 MMC_CAP_UHS_DDR50);
-}
-
+/* TODO: Move to private header */
 static inline int mmc_card_hs(struct mmc_card *card)
 {
 	return card->host->ios.timing == MMC_TIMING_SD_HS ||
 		card->host->ios.timing == MMC_TIMING_MMC_HS;
 }
 
+/* TODO: Move to private header */
 static inline int mmc_card_uhs(struct mmc_card *card)
 {
 	return card->host->ios.timing >= MMC_TIMING_UHS_SDR12 &&
 		card->host->ios.timing <= MMC_TIMING_UHS_DDR50;
 }
 
-static inline bool mmc_card_hs200(struct mmc_card *card)
-{
-	return card->host->ios.timing == MMC_TIMING_MMC_HS200;
-}
-
-static inline bool mmc_card_ddr52(struct mmc_card *card)
-{
-	return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
-}
-
-static inline bool mmc_card_hs400(struct mmc_card *card)
-{
-	return card->host->ios.timing == MMC_TIMING_MMC_HS400;
-}
-
-static inline bool mmc_card_hs400es(struct mmc_card *card)
-{
-	return card->host->ios.enhanced_strobe;
-}
-
 void mmc_retune_timer_stop(struct mmc_host *host);
 
 static inline void mmc_retune_needed(struct mmc_host *host)
@@ -531,12 +495,6 @@ static inline void mmc_retune_needed(struct mmc_host *host)
 		host->need_retune = 1;
 }
 
-static inline void mmc_retune_recheck(struct mmc_host *host)
-{
-	if (host->hold_retune <= 1)
-		host->retune_now = 1;
-}
-
 static inline bool mmc_can_retune(struct mmc_host *host)
 {
 	return host->can_retune == 1;
@@ -544,7 +502,5 @@ static inline bool mmc_can_retune(struct mmc_host *host)
 
 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
 int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
-void mmc_retune_pause(struct mmc_host *host);
-void mmc_retune_unpause(struct mmc_host *host);
 
 #endif /* LINUX_MMC_HOST_H */
Signature · 2 lines
Best Regards
Shawn Lin
#35 lore raw

PATCH v3 15/15 mmc: core: Don't use extern declarations of public mmc functions

In reply to Ulf Hansson

Using extern when declaring functions in the public header, core.h, is redundant. Let's just remove the use of it.

---
 include/linux/mmc/core.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
include/linux/mmc/core.h +9 -8
index 6440e10..6dcb339 100644
@@ -158,13 +158,14 @@ struct mmc_request {
 struct mmc_card;
 struct mmc_async_req;
 
-extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
-					   struct mmc_async_req *,
-					   enum mmc_blk_status *);
-extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
-extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
-
-extern int mmc_hw_reset(struct mmc_host *host);
-extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
+struct mmc_async_req *mmc_start_req(struct mmc_host *host,
+				struct mmc_async_req *areq,
+				enum mmc_blk_status *ret_stat);
+void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq);
+int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd,
+		int retries);
+
+int mmc_hw_reset(struct mmc_host *host);
+void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card);
 
 #endif /* LINUX_MMC_CORE_H */
Signature · 1 line
1.9.1
Reviewed-by on v3 15/15
#36 lore raw

Re: [PATCH v3 15/15] mmc: core: Don't use extern declarations of public mmc functions

Quoted 9 lines · Ulf Hansson

Using extern when declaring functions in the public header, core.h, is redundant. Let's just remove the use of it.

---
 include/linux/mmc/core.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
Quoted 28 lines
include/linux/mmc/core.h +9 -8
index 6440e10..6dcb339 100644
@@ -158,13 +158,14 @@ struct mmc_request {
 struct mmc_card;
 struct mmc_async_req;
 
-extern struct mmc_async_req *mmc_start_req(struct mmc_host *,
-					   struct mmc_async_req *,
-					   enum mmc_blk_status *);
-extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
-extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
-
-extern int mmc_hw_reset(struct mmc_host *host);
-extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
+struct mmc_async_req *mmc_start_req(struct mmc_host *host,
+				struct mmc_async_req *areq,
+				enum mmc_blk_status *ret_stat);
+void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq);
+int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd,
+		int retries);
+
+int mmc_hw_reset(struct mmc_host *host);
+void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card);
 
 #endif /* LINUX_MMC_CORE_H */
Signature · 2 lines
Best Regards
Shawn Lin
#37 lore raw
In reply to Ulf Hansson
Quoted 95 lines · Ulf Hansson

Changes in v3:
- As patch 1 was applied from version 2, it has been dropped from the series.
- Folded in a four new changes in patch 1->4/15, to solve build issues for davinci, mips and pxa.

Changes in v2:
- As patch 1->11 was applied from version 1, those have been dropped from the series.
- Folded in a new change in patch 1/12, to solve a build issue for imx which is using the mxcmmc platform data header.
- Added reviews/acks.

Ideally we should not expose functions nor structures as being public available as the interface for mmc - unless they really are intended to be used like that.

Unfortunate this is not the case today and which has lead to the mmc interface in some cases being abused. That of course has its own problems, but we can still move things in the right direction, which is what this series intend to do. More precisely, it moves things that can be easily moved from the public mmc headers to the private mmc headers.

This should be considered as a first step of improving the situation, further additional changes will have to continue this path.

Ulf Hansson (15):
ARM: pxa: Don't rely on public mmc header to include leds.h
ARM: davinci: Don't rely on public mmc header to include leds.h
ARM: davinci: Don't rely on public mmc header to include interrupt.h
MIPS: Alchemy: Don't rely on public mmc header to include interrupt.h
mmc: core: First step in cleaning up public mmc header files
mmc: core: First step in cleaning up private mmc header files
mmc: core: Move public functions from core.h to private headers
mmc: core: Move some host specific public functions to host.h
mmc: core: Move erase/trim/discard defines from public core.h to mmc.h
mmc: core: Remove unused struct _mmc_csd from public mmc.h header
mmc: omap: Don't use mmc_card_present() when validating for inserted
card
mmc: vub300: Don't use mmc_card_present() when validating for inserted
card
mmc: core: Move public functions from card.h to private headers
mmc: core: Move public functions from host.h to private headers
mmc: core: Don't use extern declarations of public mmc functions

 arch/arm/mach-davinci/board-da850-evm.c     |   1 +
 arch/arm/mach-davinci/board-dm644x-evm.c    |   1 +
 arch/arm/mach-davinci/board-neuros-osd2.c   |   1 +
 arch/arm/mach-davinci/board-omapl138-hawk.c |   1 +
 arch/arm/mach-pxa/balloon3.c                |   1 +
 arch/arm/mach-pxa/colibri-pxa270-income.c   |   1 +
 arch/arm/mach-pxa/corgi.c                   |   1 +
 arch/arm/mach-pxa/trizeps4.c                |   1 +
 arch/arm/mach-pxa/vpac270.c                 |   1 +
 arch/arm/mach-pxa/zeus.c                    |   1 +
 arch/arm/mach-pxa/zylonite.c                |   1 +
 arch/mips/alchemy/devboards/db1300.c        |   1 +
 drivers/mmc/core/block.c                    |   6 +
 drivers/mmc/core/block.h                    |   8 +
 drivers/mmc/core/bus.c                      |   2 +
 drivers/mmc/core/bus.h                      |  16 +-
 drivers/mmc/core/card.h                     | 223 +++++++++++++++++++++++++
 drivers/mmc/core/core.c                     |   1 +
 drivers/mmc/core/core.h                     |  41 ++++-
 drivers/mmc/core/debugfs.c                  |   2 +
 drivers/mmc/core/host.h                     |  48 ++++++
 drivers/mmc/core/mmc.c                      |  13 ++
 drivers/mmc/core/mmc_ops.h                  |  14 ++
 drivers/mmc/core/mmc_test.c                 |   5 +
 drivers/mmc/core/pwrseq.h                   |   6 +-
 drivers/mmc/core/queue.c                    |   2 +
 drivers/mmc/core/queue.h                    |   6 +-
 drivers/mmc/core/quirks.c                   |   2 +
 drivers/mmc/core/sd.c                       |   2 +
 drivers/mmc/core/sd.h                       |   5 +-
 drivers/mmc/core/sd_ops.h                   |   9 ++
 drivers/mmc/core/sdio.c                     |   2 +
 drivers/mmc/core/sdio_bus.c                 |   1 +
 drivers/mmc/core/sdio_bus.h                 |   3 +
 drivers/mmc/core/sdio_cis.h                 |   3 +
 drivers/mmc/core/sdio_io.c                  |   2 +
 drivers/mmc/core/sdio_irq.c                 |   2 +
 drivers/mmc/core/sdio_ops.h                 |   5 +
 drivers/mmc/core/slot-gpio.h                |   2 +
 drivers/mmc/host/omap.c                     |   2 +-
 drivers/mmc/host/vub300.c                   |   6 +-
 include/linux/mmc/card.h                    | 242 ----------------------------
 include/linux/mmc/core.h                    |  86 ++--------
 include/linux/mmc/host.h                    |  63 ++------
 include/linux/mmc/mmc.h                     |  59 ++-----
 include/linux/mmc/slot-gpio.h               |   3 +
 46 files changed, 478 insertions(+), 426 deletions(-)
 create mode 100644 drivers/mmc/core/card.h
Quoted 3 lines

--
1.9.1

I have applied this for next. Thanks everybody for reviews, acks and test. The pxa changes isn't acked yet, however I can add that later on.

Kind regards
Uffe