.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/drivers/mfd/aat2870-core.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2011, NVIDIA Corporation. |
---|
5 | 6 | * Author: Jin Park <jinyoungp@nvidia.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or |
---|
8 | | - * modify it under the terms of the GNU General Public License |
---|
9 | | - * version 2 as published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, but |
---|
12 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | | - * General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, write to the Free Software |
---|
18 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
---|
19 | | - * 02110-1301 USA |
---|
20 | 7 | */ |
---|
21 | 8 | |
---|
22 | 9 | #include <linux/kernel.h> |
---|
23 | | -#include <linux/module.h> |
---|
24 | 10 | #include <linux/init.h> |
---|
25 | 11 | #include <linux/debugfs.h> |
---|
26 | 12 | #include <linux/slab.h> |
---|
.. | .. |
---|
235 | 221 | |
---|
236 | 222 | count += sprintf(buf, "aat2870 registers\n"); |
---|
237 | 223 | for (addr = 0; addr < AAT2870_REG_NUM; addr++) { |
---|
238 | | - count += sprintf(buf + count, "0x%02x: ", addr); |
---|
| 224 | + count += snprintf(buf + count, PAGE_SIZE - count, "0x%02x: ", addr); |
---|
239 | 225 | if (count >= PAGE_SIZE - 1) |
---|
240 | 226 | break; |
---|
241 | 227 | |
---|
.. | .. |
---|
335 | 321 | static void aat2870_init_debugfs(struct aat2870_data *aat2870) |
---|
336 | 322 | { |
---|
337 | 323 | aat2870->dentry_root = debugfs_create_dir("aat2870", NULL); |
---|
338 | | - if (!aat2870->dentry_root) { |
---|
339 | | - dev_warn(aat2870->dev, |
---|
340 | | - "Failed to create debugfs root directory\n"); |
---|
341 | | - return; |
---|
342 | | - } |
---|
343 | 324 | |
---|
344 | | - aat2870->dentry_reg = debugfs_create_file("regs", 0644, |
---|
345 | | - aat2870->dentry_root, |
---|
346 | | - aat2870, &aat2870_reg_fops); |
---|
347 | | - if (!aat2870->dentry_reg) |
---|
348 | | - dev_warn(aat2870->dev, |
---|
349 | | - "Failed to create debugfs register file\n"); |
---|
| 325 | + debugfs_create_file("regs", 0644, aat2870->dentry_root, aat2870, |
---|
| 326 | + &aat2870_reg_fops); |
---|
350 | 327 | } |
---|
351 | 328 | |
---|
352 | | -static void aat2870_uninit_debugfs(struct aat2870_data *aat2870) |
---|
353 | | -{ |
---|
354 | | - debugfs_remove_recursive(aat2870->dentry_root); |
---|
355 | | -} |
---|
356 | 329 | #else |
---|
357 | 330 | static inline void aat2870_init_debugfs(struct aat2870_data *aat2870) |
---|
358 | | -{ |
---|
359 | | -} |
---|
360 | | - |
---|
361 | | -static inline void aat2870_uninit_debugfs(struct aat2870_data *aat2870) |
---|
362 | 331 | { |
---|
363 | 332 | } |
---|
364 | 333 | #endif /* CONFIG_DEBUG_FS */ |
---|
.. | .. |
---|
440 | 409 | return ret; |
---|
441 | 410 | } |
---|
442 | 411 | |
---|
443 | | -static int aat2870_i2c_remove(struct i2c_client *client) |
---|
444 | | -{ |
---|
445 | | - struct aat2870_data *aat2870 = i2c_get_clientdata(client); |
---|
446 | | - |
---|
447 | | - aat2870_uninit_debugfs(aat2870); |
---|
448 | | - |
---|
449 | | - mfd_remove_devices(aat2870->dev); |
---|
450 | | - aat2870_disable(aat2870); |
---|
451 | | - if (aat2870->uninit) |
---|
452 | | - aat2870->uninit(aat2870); |
---|
453 | | - |
---|
454 | | - return 0; |
---|
455 | | -} |
---|
456 | | - |
---|
457 | 412 | #ifdef CONFIG_PM_SLEEP |
---|
458 | 413 | static int aat2870_i2c_suspend(struct device *dev) |
---|
459 | 414 | { |
---|
.. | .. |
---|
492 | 447 | { "aat2870", 0 }, |
---|
493 | 448 | { } |
---|
494 | 449 | }; |
---|
495 | | -MODULE_DEVICE_TABLE(i2c, aat2870_i2c_id_table); |
---|
496 | 450 | |
---|
497 | 451 | static struct i2c_driver aat2870_i2c_driver = { |
---|
498 | 452 | .driver = { |
---|
499 | | - .name = "aat2870", |
---|
500 | | - .pm = &aat2870_pm_ops, |
---|
| 453 | + .name = "aat2870", |
---|
| 454 | + .pm = &aat2870_pm_ops, |
---|
| 455 | + .suppress_bind_attrs = true, |
---|
501 | 456 | }, |
---|
502 | 457 | .probe = aat2870_i2c_probe, |
---|
503 | | - .remove = aat2870_i2c_remove, |
---|
504 | 458 | .id_table = aat2870_i2c_id_table, |
---|
505 | 459 | }; |
---|
506 | 460 | |
---|
.. | .. |
---|
509 | 463 | return i2c_add_driver(&aat2870_i2c_driver); |
---|
510 | 464 | } |
---|
511 | 465 | subsys_initcall(aat2870_init); |
---|
512 | | - |
---|
513 | | -static void __exit aat2870_exit(void) |
---|
514 | | -{ |
---|
515 | | - i2c_del_driver(&aat2870_i2c_driver); |
---|
516 | | -} |
---|
517 | | -module_exit(aat2870_exit); |
---|
518 | | - |
---|
519 | | -MODULE_DESCRIPTION("Core support for the AnalogicTech AAT2870"); |
---|
520 | | -MODULE_LICENSE("GPL"); |
---|
521 | | -MODULE_AUTHOR("Jin Park <jinyoungp@nvidia.com>"); |
---|