Skip to content

Commit bf89b0b

Browse files
bzolnieraxboe
authored andcommitted
ata: make "libata.force" kernel parameter optional
Add ATA_FORCE config option (visible only if EXPERT config option is enabled) and make "libata.force" kernel parameter optional. Code size savings on m68k arch using (modified) atari_defconfig: text data bss dec hex filename w/ CONFIG_ATA_FORCE=y: 31983 572 40 32595 7f53 drivers/ata/libata-core.o w/ CONFIG_ATA_FROCE=n: 28958 316 32 29306 727a drivers/ata/libata-core.o Suggested-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a0ccd25 commit bf89b0b

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎drivers/ata/Kconfig‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ config ATA_VERBOSE_ERROR
5151

5252
If unsure, say Y.
5353

54+
config ATA_FORCE
55+
bool "\"libata.force=\" kernel parameter support" if EXPERT
56+
default y
57+
help
58+
This option adds support for "libata.force=" kernel parameter for
59+
forcing configuration settings.
60+
61+
For further information, please read
62+
<file:Documentation/admin-guide/kernel-parameters.txt>.
63+
64+
This option will enlarge the kernel by approx. 3KB. Disable it if
65+
kernel size is more important than ability to override the default
66+
configuration settings.
67+
68+
If unsure, say Y.
69+
5470
config ATA_ACPI
5571
bool "ATA ACPI Support"
5672
depends on ACPI

‎drivers/ata/libata-core.c‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
8989

9090
atomic_t ata_print_id = ATOMIC_INIT(0);
9191

92+
#ifdef CONFIG_ATA_FORCE
9293
struct ata_force_param {
9394
const char *name;
9495
u8 cbl;
@@ -112,6 +113,7 @@ static char ata_force_param_buf[COMMAND_LINE_SIZE] __initdata;
112113
/* param_buf is thrown away after initialization, disallow read */
113114
module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
114115
MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/admin-guide/kernel-parameters.rst for details)");
116+
#endif
115117

116118
static int atapi_enabled = 1;
117119
module_param(atapi_enabled, int, 0444);
@@ -303,6 +305,7 @@ struct ata_link *ata_dev_phys_link(struct ata_device *dev)
303305
return ap->slave_link;
304306
}
305307

308+
#ifdef CONFIG_ATA_FORCE
306309
/**
307310
* ata_force_cbl - force cable type according to libata.force
308311
* @ap: ATA port of interest
@@ -483,6 +486,11 @@ static void ata_force_horkage(struct ata_device *dev)
483486
fe->param.name);
484487
}
485488
}
489+
#else
490+
static inline void ata_force_link_limits(struct ata_link *link) { }
491+
static inline void ata_force_xfermask(struct ata_device *dev) { }
492+
static inline void ata_force_horkage(struct ata_device *dev) { }
493+
#endif
486494

487495
/**
488496
* atapi_cmd_type - Determine ATAPI command type from SCSI opcode
@@ -6080,6 +6088,7 @@ int ata_platform_remove_one(struct platform_device *pdev)
60806088
}
60816089
EXPORT_SYMBOL_GPL(ata_platform_remove_one);
60826090

6091+
#ifdef CONFIG_ATA_FORCE
60836092
static int __init ata_parse_force_one(char **cur,
60846093
struct ata_force_ent *force_ent,
60856094
const char **reason)
@@ -6259,6 +6268,15 @@ static void __init ata_parse_force_param(void)
62596268
ata_force_tbl_size = idx;
62606269
}
62616270

6271+
static void ata_free_force_param(void)
6272+
{
6273+
kfree(ata_force_tbl);
6274+
}
6275+
#else
6276+
static inline void ata_parse_force_param(void) { }
6277+
static inline void ata_free_force_param(void) { }
6278+
#endif
6279+
62626280
static int __init ata_init(void)
62636281
{
62646282
int rc;
@@ -6267,7 +6285,7 @@ static int __init ata_init(void)
62676285

62686286
rc = ata_sff_init();
62696287
if (rc) {
6270-
kfree(ata_force_tbl);
6288+
ata_free_force_param();
62716289
return rc;
62726290
}
62736291

@@ -6291,7 +6309,7 @@ static void __exit ata_exit(void)
62916309
ata_release_transport(ata_scsi_transport_template);
62926310
libata_transport_exit();
62936311
ata_sff_exit();
6294-
kfree(ata_force_tbl);
6312+
ata_free_force_param();
62956313
}
62966314

62976315
subsys_initcall(ata_init);

‎drivers/ata/libata.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ extern int libata_noacpi;
3737
extern int libata_allow_tpm;
3838
extern const struct device_type ata_port_type;
3939
extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
40+
#ifdef CONFIG_ATA_FORCE
4041
extern void ata_force_cbl(struct ata_port *ap);
42+
#else
43+
static inline void ata_force_cbl(struct ata_port *ap) { }
44+
#endif
4145
extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
4246
extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
4347
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);

0 commit comments

Comments
 (0)