| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Debugfs support for hosts and cards |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2008 Atmel Corporation |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | #include <linux/moduleparam.h> |
|---|
| 11 | 8 | #include <linux/export.h> |
|---|
| .. | .. |
|---|
| 222 | 219 | return 0; |
|---|
| 223 | 220 | } |
|---|
| 224 | 221 | |
|---|
| 225 | | -DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, |
|---|
| 226 | | - "%llu\n"); |
|---|
| 227 | | - |
|---|
| 228 | | -static int mmc_max_clock_opt_get(void *data, u64 *val) |
|---|
| 229 | | -{ |
|---|
| 230 | | - struct mmc_host *host = data; |
|---|
| 231 | | - |
|---|
| 232 | | - *val = host->f_max; |
|---|
| 233 | | - |
|---|
| 234 | | - return 0; |
|---|
| 235 | | -} |
|---|
| 236 | | - |
|---|
| 237 | | -static int mmc_max_clock_opt_set(void *data, u64 val) |
|---|
| 238 | | -{ |
|---|
| 239 | | - struct mmc_host *host = data; |
|---|
| 240 | | - |
|---|
| 241 | | - /* We need this check due to input value is u64 */ |
|---|
| 242 | | - if (val != 0 && (val > UHS_SDR104_MAX_DTR || val < host->f_min)) |
|---|
| 243 | | - return -EINVAL; |
|---|
| 244 | | - |
|---|
| 245 | | - host->f_max = (unsigned int) val; |
|---|
| 246 | | - |
|---|
| 247 | | - return 0; |
|---|
| 248 | | -} |
|---|
| 249 | | - |
|---|
| 250 | | -DEFINE_DEBUGFS_ATTRIBUTE(mmc_max_clock_fops, mmc_max_clock_opt_get, mmc_max_clock_opt_set, |
|---|
| 222 | +DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, |
|---|
| 251 | 223 | "%llu\n"); |
|---|
| 252 | 224 | |
|---|
| 253 | 225 | void mmc_add_host_debugfs(struct mmc_host *host) |
|---|
| .. | .. |
|---|
| 255 | 227 | struct dentry *root; |
|---|
| 256 | 228 | |
|---|
| 257 | 229 | root = debugfs_create_dir(mmc_hostname(host), NULL); |
|---|
| 258 | | - if (IS_ERR(root)) |
|---|
| 259 | | - /* Don't complain -- debugfs just isn't enabled */ |
|---|
| 260 | | - return; |
|---|
| 261 | | - if (!root) |
|---|
| 262 | | - /* Complain -- debugfs is enabled, but it failed to |
|---|
| 263 | | - * create the directory. */ |
|---|
| 264 | | - goto err_root; |
|---|
| 265 | | - |
|---|
| 266 | 230 | host->debugfs_root = root; |
|---|
| 267 | 231 | |
|---|
| 268 | | - if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops)) |
|---|
| 269 | | - goto err_node; |
|---|
| 270 | | - |
|---|
| 271 | | - if (!debugfs_create_x32("caps", S_IRUSR, root, &host->caps)) |
|---|
| 272 | | - goto err_node; |
|---|
| 273 | | - |
|---|
| 274 | | - if (!debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2)) |
|---|
| 275 | | - goto err_node; |
|---|
| 276 | | - |
|---|
| 277 | | - if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host, |
|---|
| 278 | | - &mmc_clock_fops)) |
|---|
| 279 | | - goto err_node; |
|---|
| 280 | | - |
|---|
| 281 | | - debugfs_create_file_unsafe("max_clock", S_IRUSR | S_IWUSR, root, host, |
|---|
| 282 | | - &mmc_max_clock_fops); |
|---|
| 232 | + debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops); |
|---|
| 233 | + debugfs_create_x32("caps", S_IRUSR, root, &host->caps); |
|---|
| 234 | + debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2); |
|---|
| 235 | + debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host, |
|---|
| 236 | + &mmc_clock_fops); |
|---|
| 283 | 237 | |
|---|
| 284 | 238 | #ifdef CONFIG_FAIL_MMC_REQUEST |
|---|
| 285 | 239 | if (fail_request) |
|---|
| 286 | 240 | setup_fault_attr(&fail_default_attr, fail_request); |
|---|
| 287 | 241 | host->fail_mmc_request = fail_default_attr; |
|---|
| 288 | | - if (IS_ERR(fault_create_debugfs_attr("fail_mmc_request", |
|---|
| 289 | | - root, |
|---|
| 290 | | - &host->fail_mmc_request))) |
|---|
| 291 | | - goto err_node; |
|---|
| 242 | + fault_create_debugfs_attr("fail_mmc_request", root, |
|---|
| 243 | + &host->fail_mmc_request); |
|---|
| 292 | 244 | #endif |
|---|
| 293 | | - return; |
|---|
| 294 | | - |
|---|
| 295 | | -err_node: |
|---|
| 296 | | - debugfs_remove_recursive(root); |
|---|
| 297 | | - host->debugfs_root = NULL; |
|---|
| 298 | | -err_root: |
|---|
| 299 | | - dev_err(&host->class_dev, "failed to initialize debugfs\n"); |
|---|
| 300 | 245 | } |
|---|
| 301 | 246 | |
|---|
| 302 | 247 | void mmc_remove_host_debugfs(struct mmc_host *host) |
|---|
| .. | .. |
|---|
| 313 | 258 | return; |
|---|
| 314 | 259 | |
|---|
| 315 | 260 | root = debugfs_create_dir(mmc_card_id(card), host->debugfs_root); |
|---|
| 316 | | - if (IS_ERR(root)) |
|---|
| 317 | | - /* Don't complain -- debugfs just isn't enabled */ |
|---|
| 318 | | - return; |
|---|
| 319 | | - if (!root) |
|---|
| 320 | | - /* Complain -- debugfs is enabled, but it failed to |
|---|
| 321 | | - * create the directory. */ |
|---|
| 322 | | - goto err; |
|---|
| 323 | | - |
|---|
| 324 | 261 | card->debugfs_root = root; |
|---|
| 325 | 262 | |
|---|
| 326 | | - if (!debugfs_create_x32("state", S_IRUSR, root, &card->state)) |
|---|
| 327 | | - goto err; |
|---|
| 328 | | - |
|---|
| 329 | | - return; |
|---|
| 330 | | - |
|---|
| 331 | | -err: |
|---|
| 332 | | - debugfs_remove_recursive(root); |
|---|
| 333 | | - card->debugfs_root = NULL; |
|---|
| 334 | | - dev_err(&card->dev, "failed to initialize debugfs\n"); |
|---|
| 263 | + debugfs_create_x32("state", S_IRUSR, root, &card->state); |
|---|
| 335 | 264 | } |
|---|
| 336 | 265 | |
|---|
| 337 | 266 | void mmc_remove_card_debugfs(struct mmc_card *card) |
|---|