Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c-s3c2410: move to using platform idtable to match devices

Change to using platform id table to match either of the two supported
platform device names in the driver. This simplifies the driver init and
exit code

Note, log messages will now be prefixed with 's3c-i2c' instead of the
driver name, so output will be of the form of:

s3c-i2c s3c2440-i2c.0: slave address 0x10

Signed-off-by: Ben Dooks <ben-linux@fluff.org>

Ben Dooks 7d85ccd8 84bf2c86

+22 -26
+22 -26
drivers/i2c/busses/i2c-s3c2410.c
··· 51 51 STATE_STOP 52 52 }; 53 53 54 + enum s3c24xx_i2c_type { 55 + TYPE_S3C2410, 56 + TYPE_S3C2440, 57 + }; 58 + 54 59 struct s3c24xx_i2c { 55 60 spinlock_t lock; 56 61 wait_queue_head_t wait; ··· 93 88 static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c) 94 89 { 95 90 struct platform_device *pdev = to_platform_device(i2c->dev); 91 + enum s3c24xx_i2c_type type; 96 92 97 - return !strcmp(pdev->name, "s3c2440-i2c"); 93 + type = platform_get_device_id(pdev)->driver_data; 94 + return type == TYPE_S3C2440; 98 95 } 99 96 100 97 /* s3c24xx_i2c_master_complete ··· 976 969 977 970 /* device driver for platform bus bits */ 978 971 979 - static struct platform_driver s3c2410_i2c_driver = { 980 - .probe = s3c24xx_i2c_probe, 981 - .remove = s3c24xx_i2c_remove, 982 - .suspend_late = s3c24xx_i2c_suspend_late, 983 - .resume = s3c24xx_i2c_resume, 984 - .driver = { 985 - .owner = THIS_MODULE, 986 - .name = "s3c2410-i2c", 987 - }, 972 + static struct platform_device_id s3c24xx_driver_ids[] = { 973 + { 974 + .name = "s3c2410-i2c", 975 + .driver_data = TYPE_S3C2410, 976 + }, { 977 + .name = "s3c2440-i2c", 978 + .driver_data = TYPE_S3C2440, 979 + }, { }, 988 980 }; 981 + MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); 989 982 990 - static struct platform_driver s3c2440_i2c_driver = { 983 + static struct platform_driver s3c24xx_i2c_driver = { 991 984 .probe = s3c24xx_i2c_probe, 992 985 .remove = s3c24xx_i2c_remove, 993 986 .suspend_late = s3c24xx_i2c_suspend_late, 994 987 .resume = s3c24xx_i2c_resume, 988 + .id_table = s3c24xx_driver_ids, 995 989 .driver = { 996 990 .owner = THIS_MODULE, 997 - .name = "s3c2440-i2c", 991 + .name = "s3c-i2c", 998 992 }, 999 993 }; 1000 994 1001 995 static int __init i2c_adap_s3c_init(void) 1002 996 { 1003 - int ret; 1004 - 1005 - ret = platform_driver_register(&s3c2410_i2c_driver); 1006 - if (ret == 0) { 1007 - ret = platform_driver_register(&s3c2440_i2c_driver); 1008 - if (ret) 1009 - platform_driver_unregister(&s3c2410_i2c_driver); 1010 - } 1011 - 1012 - return ret; 997 + return platform_driver_register(&s3c24xx_i2c_driver); 1013 998 } 1014 999 subsys_initcall(i2c_adap_s3c_init); 1015 1000 1016 1001 static void __exit i2c_adap_s3c_exit(void) 1017 1002 { 1018 - platform_driver_unregister(&s3c2410_i2c_driver); 1019 - platform_driver_unregister(&s3c2440_i2c_driver); 1003 + platform_driver_unregister(&s3c24xx_i2c_driver); 1020 1004 } 1021 1005 module_exit(i2c_adap_s3c_exit); 1022 1006 1023 1007 MODULE_DESCRIPTION("S3C24XX I2C Bus driver"); 1024 1008 MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); 1025 1009 MODULE_LICENSE("GPL"); 1026 - MODULE_ALIAS("platform:s3c2410-i2c"); 1027 - MODULE_ALIAS("platform:s3c2440-i2c");