From nobody Sat Feb 7 17:42:10 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 492EE225417 for ; Mon, 5 Jan 2026 06:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767595577; cv=none; b=l0qv+Y+nUHOs0IZy3B4gvKwg/QRaEcohraR4zFmeGLgjPM86qG9kDucgCpKHh1miLgk/LazJg0oGKfRhSRYALdZVfotPkJy9huARoe4vEzoKYdq1OphKHOkURweyjYy9zGFVafbB8d3vaKpKhV0G5UcoddN7Ntx8rJQsyjZ5rwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767595577; c=relaxed/simple; bh=8U1kE3jep3pvKVeHM6RwIuITuKbmiyH88Hmm5ceYZg4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ibQYd4B+8z8TjHd3TJsjX3L0Nm49sR9FZ2gZ3RPVCshcvuVaCJF+hlrUubApFGTAxLGtOCU0I41/LWp11GtCqHD1thsU/Vo5ehbQXvDhw96IY58WaLCCcqQUEbjAKbsxckZB+Itb5PNX7Revo4OtaeqyT1B1fQ5cQ0tfUTtBTxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=V0xLefLA; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="V0xLefLA" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7b8eff36e3bso21270256b3a.2 for ; Sun, 04 Jan 2026 22:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1767595574; x=1768200374; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fIvba1dtnjACs/yRHiJzbXUQbVZum9CYzrKlL1W069s=; b=V0xLefLAtmjFuxP1KoJIenNr/nKqBqX6V+4Tx+13vketRl3X0K/BE605n7Mv248C+l 4z6C9YSjwl9GDM8i98oud1EliFYEn25g++bCKcdRthtmjK6C8C3cuW+v+MUrtYOsLbu0 EjxFy12CxPB2NlYholsXwSKxS7qEJgCwTASh0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767595574; x=1768200374; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fIvba1dtnjACs/yRHiJzbXUQbVZum9CYzrKlL1W069s=; b=uKQTCMXTWz01rOZ9CbulnwlXLXujk+F/PQa/82m4vHF97rE9KERJF3V6HSMJP9GFL9 XKcv1mutbAJRJdYws9sLiml+K6LaIU/khjFOPhC2n4+Tq54gBDiQm9XxszKiYaR6ImCW 3DmWZR00Qr/FOJPiXj8fgcQFTGUFyq2YzIdZyux5x2KW26UJyyFNlE43g1nKZch2sLQi DCp5YqRWIEx5SqzIN6UjOiA7mlsY22CIfk3fYSDROFHbiFw/XZjiP4iEjw/dJR3mEbz3 eI7KM2jqTpMqeMMGEYO6zlZgCLLWl+7YSqHbpHrffzkobxG4XHujzxuhJDqk3zouJEUL s4Kg== X-Gm-Message-State: AOJu0Yw8ju8H+HbMPW+GTiBXF2NFFD+4Q4GAU5vCqi6nrh+BHXA0W52s 0MazZIDdOcEQu5Ipml5F0NkPceCWb2K1ZDPdR1DUXwFI8v+XT52j2gwokTQqvzMPoDE= X-Gm-Gg: AY/fxX6nurS3zSNW4BBDLaXVyYzCQ0Ap168gCPJf66q2fw8WGwEn/SiBPijeOk+COOV iql0hPHRBe2raBj2XN9vLgWCO7+c6cLPs778AqV+7KW0Y7ZC/Jbd/j7TprExYCxMPXNpRXMiwhk eNdHR9GsGPodJp3v34szrtefNiFi57Z7WnFMoxER0b9xyWC1dHzWHNfIiEqF65aY+cjh0QOtzIJ hYbZyEONooL8ppf7ydca2pAvUvC2rEz5VfO/Ii7nj8sq1cbVpXG2sSZmmoWJZ4vPdfrYJeNVrkk WBN8cOApY5Z/CuGh4laY6YKuDDHBHB/Nf213V77VhtC/PjchDWLlF6HhA/+l1jqN8LkYvxG8kln 0uX2rYnVBrT0Xp+BTvqYHNT76XUMQyJzH0beueRHqy7eZPC1hepDYjTmyTqE3sDhdGrmmB3hs2T 3/+oGgKU6+Jq9ycr4ObVEPEoZlFzl5QvP96hTw8+1Gbqf/ktTp8iajJB5VCBcGyd98YmRETEsB/ mM= X-Google-Smtp-Source: AGHT+IFyiAnho/hOZgOid83U5bBcIhekELzt+KCSFr/GAoPB4oDyM0auPkadxsFuf2d8abmC2+1tqw== X-Received: by 2002:a05:6a20:6a06:b0:34f:1623:2354 with SMTP id adf61e73a8af0-376aa4fc36dmr50058842637.42.1767595574392; Sun, 04 Jan 2026 22:46:14 -0800 (PST) Received: from kinako.work.home.arpa (p1536247-ipxg00c01sizuokaden.shizuoka.ocn.ne.jp. [122.26.212.247]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-c1e7c143aa8sm40938853a12.24.2026.01.04.22.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 22:46:13 -0800 (PST) From: Daniel Palmer To: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Daniel Palmer Subject: [RFC PATCH] mmc: sdio: Allow sdio code to be build time disabled Date: Mon, 5 Jan 2026 15:46:07 +0900 Message-ID: <20260105064607.1554629-1-daniel@thingy.jp> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some cases the sdio support is not needed but the compiler cannot tell this and it ends up in your binary. This might not matter so much on generic kernels for systems with gigabytes of memory but in situations with megabytes of memory that just have an SD card attached via bitbanged SPI over GPIO this is wasteful. For amd64 disabling SDIO reduces the size of the kernel by ~26KiB. Signed-off-by: Daniel Palmer --- RFC because this is probably incomplete, maybe not a good idea,.. I have only tested that this removes the unneeded SDIO code on my machine with 8MB of RAM and its still able to enumerate and access a 64GB SD card it has connected over SPI. drivers/mmc/core/Kconfig | 12 +++++++++++- drivers/mmc/core/Makefile | 6 +++--- drivers/mmc/core/core.h | 7 +++++++ drivers/mmc/core/host.c | 2 ++ drivers/mmc/core/sdio_bus.h | 5 +++++ drivers/mmc/core/sdio_cis.h | 4 ++++ drivers/mmc/core/sdio_ops.h | 14 ++++++++++++++ 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig index 14d2ecbb04d3..4112242a6c98 100644 --- a/drivers/mmc/core/Kconfig +++ b/drivers/mmc/core/Kconfig @@ -64,9 +64,19 @@ config MMC_BLOCK_MINORS =20 If unsure, say 8 here. =20 +config MMC_SDIO + bool "Support SDIO in MMC core" if EXPERT + default y + help + Enable SDIO support in the MMC core. If you will never use + SDIO because your hardware can't support it or your usecase + will never need it i.e. you have one SD host and it has fixed + eMMC attached to it you can set this to N and remove some + unneeded code. + config SDIO_UART tristate "SDIO UART/GPS class support" - depends on TTY + depends on MMC_SDIO && TTY help SDIO function driver for SDIO cards that implements the UART class, as well as the GPS class which appears like a UART. diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile index 15b067e8b0d1..efc354150e8a 100644 --- a/drivers/mmc/core/Makefile +++ b/drivers/mmc/core/Makefile @@ -6,9 +6,9 @@ obj-$(CONFIG_MMC) +=3D mmc_core.o mmc_core-y :=3D core.o bus.o host.o \ mmc.o mmc_ops.o sd.o sd_ops.o \ - sdio.o sdio_ops.o sdio_bus.o \ - sdio_cis.o sdio_io.o sdio_irq.o sd_uhs2.o\ - slot-gpio.o regulator.o + sd_uhs2.o slot-gpio.o regulator.o +mmc_core-$(CONFIG_MMC_SDIO) +=3D sdio.o sdio_ops.o sdio_bus.o \ + sdio_cis.o sdio_io.o sdio_irq.o mmc_core-$(CONFIG_OF) +=3D pwrseq.o obj-$(CONFIG_PWRSEQ_SIMPLE) +=3D pwrseq_simple.o obj-$(CONFIG_PWRSEQ_SD8787) +=3D pwrseq_sd8787.o diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index a028b48be164..8e2a1abc5523 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -85,7 +85,14 @@ int mmc_detect_card_removed(struct mmc_host *host); =20 int mmc_attach_mmc(struct mmc_host *host); int mmc_attach_sd(struct mmc_host *host); +#ifdef CONFIG_MMC_SDIO int mmc_attach_sdio(struct mmc_host *host); +#else +static inline int mmc_attach_sdio(struct mmc_host *host) +{ + return -EOPNOTSUPP; +} +#endif int mmc_attach_sd_uhs2(struct mmc_host *host); =20 /* Module parameters */ diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 88c95dbfd9cf..0216953b8906 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -563,7 +563,9 @@ struct mmc_host *mmc_alloc_host(int extra, struct devic= e *dev) spin_lock_init(&host->lock); init_waitqueue_head(&host->wq); INIT_DELAYED_WORK(&host->detect, mmc_rescan); +#ifdef CONFIG_MMC_SDIO INIT_WORK(&host->sdio_irq_work, sdio_irq_work); +#endif timer_setup(&host->retune_timer, mmc_retune_timer, 0); =20 INIT_WORK(&host->supply.uv_work, mmc_undervoltage_workfn); diff --git a/drivers/mmc/core/sdio_bus.h b/drivers/mmc/core/sdio_bus.h index 27b8069a72ab..ad14784b37d1 100644 --- a/drivers/mmc/core/sdio_bus.h +++ b/drivers/mmc/core/sdio_bus.h @@ -14,8 +14,13 @@ 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); =20 +#ifdef CONFIG_MMC_SDIO int sdio_register_bus(void); void sdio_unregister_bus(void); +#else +#define sdio_register_bus() 0 +#define sdio_unregister_bus() +#endif =20 #endif =20 diff --git a/drivers/mmc/core/sdio_cis.h b/drivers/mmc/core/sdio_cis.h index 6d76f6fa608c..486eeb802162 100644 --- a/drivers/mmc/core/sdio_cis.h +++ b/drivers/mmc/core/sdio_cis.h @@ -13,10 +13,14 @@ struct mmc_card; struct sdio_func; =20 +#ifdef CONFIG_MMC_SDIO int sdio_read_common_cis(struct mmc_card *card); void sdio_free_common_cis(struct mmc_card *card); =20 int sdio_read_func_cis(struct sdio_func *func); void sdio_free_func_cis(struct sdio_func *func); +#else +#define sdio_free_common_cis(card) +#endif =20 #endif diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index 37f79732a206..dc16e80aa361 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h @@ -12,6 +12,7 @@ #include =20 struct mmc_host; +#ifdef CONFIG_MMC_SDIO struct mmc_card; struct work_struct; =20 @@ -33,6 +34,19 @@ static inline bool sdio_is_io_busy(u32 opcode, u32 arg) (opcode =3D=3D SD_IO_RW_DIRECT && !(addr =3D=3D SDIO_CCCR_ABORT || addr =3D=3D SDIO_CCCR_SUSPEND))); } +#else +/* These are referenced in code outside of the sdio files so define dummy = versions */ +static inline int sdio_reset(struct mmc_host *host) +{ + return 0; +} + +static inline bool sdio_is_io_busy(u32 opcode, u32 arg) +{ + return false; +} +#endif + =20 #endif =20 --=20 2.51.0