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

mfd: Switch AB3100 to use MFD cells

This switches the AB3100 core driver to using MFD cells for
subdevices instead of spawning common platform devices.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Linus Walleij and committed by
Samuel Ortiz
8c96aefb 2524468e

+69 -61
+1
drivers/mfd/Kconfig
··· 444 444 config AB3100_CORE 445 445 bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions" 446 446 depends on I2C=y && ABX500_CORE 447 + select MFD_CORE 447 448 default y if ARCH_U300 448 449 help 449 450 Select this to enable the AB3100 Mixed Signal IC core
+68 -61
drivers/mfd/ab3100-core.c
··· 19 19 #include <linux/debugfs.h> 20 20 #include <linux/seq_file.h> 21 21 #include <linux/uaccess.h> 22 + #include <linux/mfd/core.h> 22 23 #include <linux/mfd/abx500.h> 23 24 24 25 /* These are the only registers inside AB3100 used in this main file */ ··· 147 146 } 148 147 149 148 static int ab3100_get_register_interruptible(struct ab3100 *ab3100, 150 - u8 reg, u8 *regval) 149 + u8 reg, u8 *regval) 151 150 { 152 151 int err; 153 152 ··· 203 202 } 204 203 205 204 static int get_register_interruptible(struct device *dev, u8 bank, u8 reg, 206 - u8 *value) 205 + u8 *value) 207 206 { 208 207 struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); 209 208 ··· 744 743 return err; 745 744 } 746 745 747 - /* 748 - * Here we define all the platform devices that appear 749 - * as children of the AB3100. These are regular platform 750 - * devices with the IORESOURCE_IO .start and .end set 751 - * to correspond to the internal AB3100 register range 752 - * mapping to the corresponding subdevice. 753 - */ 754 - 755 - #define AB3100_DEVICE(devname, devid) \ 756 - static struct platform_device ab3100_##devname##_device = { \ 757 - .name = devid, \ 758 - .id = -1, \ 759 - } 760 - 761 - /* This lists all the subdevices */ 762 - AB3100_DEVICE(dac, "ab3100-dac"); 763 - AB3100_DEVICE(leds, "ab3100-leds"); 764 - AB3100_DEVICE(power, "ab3100-power"); 765 - AB3100_DEVICE(regulators, "ab3100-regulators"); 766 - AB3100_DEVICE(sim, "ab3100-sim"); 767 - AB3100_DEVICE(uart, "ab3100-uart"); 768 - AB3100_DEVICE(rtc, "ab3100-rtc"); 769 - AB3100_DEVICE(charger, "ab3100-charger"); 770 - AB3100_DEVICE(boost, "ab3100-boost"); 771 - AB3100_DEVICE(adc, "ab3100-adc"); 772 - AB3100_DEVICE(fuelgauge, "ab3100-fuelgauge"); 773 - AB3100_DEVICE(vibrator, "ab3100-vibrator"); 774 - AB3100_DEVICE(otp, "ab3100-otp"); 775 - AB3100_DEVICE(codec, "ab3100-codec"); 776 - 777 - static struct platform_device * 778 - ab3100_platform_devs[] = { 779 - &ab3100_dac_device, 780 - &ab3100_leds_device, 781 - &ab3100_power_device, 782 - &ab3100_regulators_device, 783 - &ab3100_sim_device, 784 - &ab3100_uart_device, 785 - &ab3100_rtc_device, 786 - &ab3100_charger_device, 787 - &ab3100_boost_device, 788 - &ab3100_adc_device, 789 - &ab3100_fuelgauge_device, 790 - &ab3100_vibrator_device, 791 - &ab3100_otp_device, 792 - &ab3100_codec_device, 746 + /* The subdevices of the AB3100 */ 747 + static struct mfd_cell ab3100_devs[] = { 748 + { 749 + .name = "ab3100-dac", 750 + .id = -1, 751 + }, 752 + { 753 + .name = "ab3100-leds", 754 + .id = -1, 755 + }, 756 + { 757 + .name = "ab3100-power", 758 + .id = -1, 759 + }, 760 + { 761 + .name = "ab3100-regulators", 762 + .id = -1, 763 + }, 764 + { 765 + .name = "ab3100-sim", 766 + .id = -1, 767 + }, 768 + { 769 + .name = "ab3100-uart", 770 + .id = -1, 771 + }, 772 + { 773 + .name = "ab3100-rtc", 774 + .id = -1, 775 + }, 776 + { 777 + .name = "ab3100-charger", 778 + .id = -1, 779 + }, 780 + { 781 + .name = "ab3100-boost", 782 + .id = -1, 783 + }, 784 + { 785 + .name = "ab3100-adc", 786 + .id = -1, 787 + }, 788 + { 789 + .name = "ab3100-fuelgauge", 790 + .id = -1, 791 + }, 792 + { 793 + .name = "ab3100-vibrator", 794 + .id = -1, 795 + }, 796 + { 797 + .name = "ab3100-otp", 798 + .id = -1, 799 + }, 800 + { 801 + .name = "ab3100-codec", 802 + .id = -1, 803 + }, 793 804 }; 794 805 795 806 struct ab_family_id { ··· 948 935 if (err) 949 936 goto exit_no_ops; 950 937 951 - /* Set parent and a pointer back to the container in device data */ 952 - for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) { 953 - ab3100_platform_devs[i]->dev.parent = 954 - &client->dev; 955 - ab3100_platform_devs[i]->dev.platform_data = 956 - ab3100_plf_data; 957 - platform_set_drvdata(ab3100_platform_devs[i], ab3100); 938 + /* Set up and register the platform devices. */ 939 + for (i = 0; i < ARRAY_SIZE(ab3100_devs); i++) { 940 + ab3100_devs[i].platform_data = ab3100_plf_data; 941 + ab3100_devs[i].data_size = sizeof(struct ab3100_platform_data); 958 942 } 959 943 960 - /* Register the platform devices */ 961 - platform_add_devices(ab3100_platform_devs, 962 - ARRAY_SIZE(ab3100_platform_devs)); 944 + err = mfd_add_devices(&client->dev, 0, ab3100_devs, 945 + ARRAY_SIZE(ab3100_devs), NULL, 0); 963 946 964 947 ab3100_setup_debugfs(ab3100); 965 948 ··· 974 965 static int __devexit ab3100_remove(struct i2c_client *client) 975 966 { 976 967 struct ab3100 *ab3100 = i2c_get_clientdata(client); 977 - int i; 978 968 979 969 /* Unregister subdevices */ 980 - for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) 981 - platform_device_unregister(ab3100_platform_devs[i]); 970 + mfd_remove_devices(&client->dev); 982 971 983 972 ab3100_remove_debugfs(); 984 973 i2c_unregister_device(ab3100->testreg_client);