mmc: core: A start to slim down public mmc headers
Subsystems (3)
v2 cover mmc: core: A start to slim down public mmc headers
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 (12):
mmc: mxcmmc: Include interrupt.h in the platform data header
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
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 + include/linux/platform_data/mmc-mxcmmc.h | 1 + 35 files changed, 467 insertions(+), 426 deletions(-) create mode 100644 drivers/mmc/core/card.h
Signature · 1 line
1.9.1
PATCH v2 1/12 mmc: mxcmmc: Include interrupt.h in the platform data header
The mxcmmc platform data header depends on interrupt.h. Don't rely on the public mmc header host.h to include it, bud instead make that dependency explicit.
--- include/linux/platform_data/mmc-mxcmmc.h | 1 + 1 file changed, 1 insertion(+)
include/linux/platform_data/mmc-mxcmmc.h +1 -0
@@ -1,6 +1,7 @@#ifndef ASMARM_ARCH_MMC_H #define ASMARM_ARCH_MMC_H +#include <linux/interrupt.h> #include <linux/mmc/host.h> struct device ;
Signature · 1 line
1.9.1
PATCH v2 2/12 mmc: core: First step in cleaning up public mmc header files
In reply to Ulf HanssonThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 3/12 mmc: core: First step in cleaning up private mmc header files
In reply to Ulf HanssonThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 4/12 mmc: core: Move public functions from core.h to private headers
In reply to Ulf HanssonA 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 5/12 mmc: core: Move some host specific public functions to host.h
In reply to Ulf HanssonIdeally 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
@@ -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
@@ -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
PATCH v2 6/12 mmc: core: Move erase/trim/discard defines from public core.h to mmc.h
In reply to Ulf HanssonAs 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
@@ -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
@@ -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
PATCH v2 7/12 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
@@ -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
PATCH v2 8/12 mmc: omap: Don't use mmc_card_present() when validating for inserted card
In reply to Ulf HanssonThe 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
@@ -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
PATCH v2 9/12 mmc: vub300: Don't use mmc_card_present() when validating for inserted card
In reply to Ulf HanssonThe 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
@@ -728,8 +728,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
@@ -1756,8 +1755,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
PATCH v2 10/12 mmc: core: Move public functions from card.h to private headers
In reply to Ulf HanssonA 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 11/12 mmc: core: Move public functions from host.h to private headers
In reply to Ulf HanssonA 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 12/12 mmc: core: Don't use extern declarations of public mmc functions
In reply to Ulf HanssonUsing 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
@@ -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
Quoted 75 lines · Ulf Hansson
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 (12):
mmc: mxcmmc: Includeinterrupt.hin the platform data header
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 fromcore.hto private headers
mmc: core: Move some host specific public functions tohost.h
mmc: core: Move erase/trim/discard defines from publiccore.htommc.h
mmc: core: Remove unused struct_mmc_csdfrom publicmmc.hheader
mmc: omap: Don't usemmc_card_present()when validating for inserted
card
mmc: vub300: Don't usemmc_card_present()when validating for inserted
card
mmc: core: Move public functions fromcard.hto private headers
mmc: core: Move public functions fromhost.hto private headers
mmc: core: Don't use extern declarations of public mmc functionsdrivers/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 + include/linux/platform_data/mmc-mxcmmc.h | 1 + 35 files changed, 467 insertions(+), 426 deletions(-) create mode 100644 drivers/mmc/core/card.h
Quoted 3 lines
--
1.9.1
I have now applied this for next to get it well tested. Please tell asap, if you have any objections.
Kind regards
Uffe
Quoted 76 lines · Ulf Hansson
Quoted 75 lines · Ulf Hansson
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 (12):
mmc: mxcmmc: Includeinterrupt.hin the platform data header
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 fromcore.hto private headers
mmc: core: Move some host specific public functions tohost.h
mmc: core: Move erase/trim/discard defines from publiccore.htommc.h
mmc: core: Remove unused struct_mmc_csdfrom publicmmc.hheader
mmc: omap: Don't usemmc_card_present()when validating for inserted
card
mmc: vub300: Don't usemmc_card_present()when validating for inserted
card
mmc: core: Move public functions fromcard.hto private headers
mmc: core: Move public functions fromhost.hto private headers
mmc: core: Don't use extern declarations of public mmc functionsdrivers/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 + include/linux/platform_data/mmc-mxcmmc.h | 1 + 35 files changed, 467 insertions(+), 426 deletions(-) create mode 100644 drivers/mmc/core/card.h
Quoted 6 lines
Quoted 3 lines
--
1.9.1I have now applied this for next to get it well tested. Please tell asap, if you have any objections.
Dropping patch 2 and onwards from my next branch, because of build issues for some arm/mips SoCs, reported by kernelci.
https://kernelci.org/build/ulfh/kernel/v4.10-rc3-64-g656ac692663b/
I will look into the issues more closely tomorrow morning.
Kind regards
Uffe