Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
"Some bugfixes from I2C:

- fix a uevent triggered boot problem by removing a useless debug
print

- fix sysfs-attributes of the new i2c-demux-pinctrl driver to follow
standard kernel behaviour

- fix a potential division-by-zero error (needed two takes)"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: jz4780: really prevent potential division by zero
Revert "i2c: jz4780: prevent potential division by zero"
i2c: jz4780: prevent potential division by zero
i2c: mux: demux-pinctrl: Update docs to new sysfs-attributes
i2c: mux: demux-pinctrl: Clean up sysfs attributes
i2c: prevent endless uevent loop with CONFIG_I2C_DEBUG_CORE

Changed files
+49 -36
Documentation
drivers
+12 -17
Documentation/ABI/testing/sysfs-platform-i2c-demux-pinctrl
··· 1 - What: /sys/devices/platform/<i2c-demux-name>/cur_master 1 + What: /sys/devices/platform/<i2c-demux-name>/available_masters 2 2 Date: January 2016 3 3 KernelVersion: 4.6 4 4 Contact: Wolfram Sang <wsa@the-dreams.de> 5 5 Description: 6 + Reading the file will give you a list of masters which can be 7 + selected for a demultiplexed bus. The format is 8 + "<index>:<name>". Example from a Renesas Lager board: 6 9 7 - This file selects the active I2C master for a demultiplexed bus. 10 + 0:/i2c@e6500000 1:/i2c@e6508000 8 11 9 - Write 0 there for the first master, 1 for the second etc. Reading the file will 10 - give you a list with the active master marked. Example from a Renesas Lager 11 - board: 12 - 13 - root@Lager:~# cat /sys/devices/platform/i2c@8/cur_master 14 - * 0 - /i2c@9 15 - 1 - /i2c@e6520000 16 - 2 - /i2c@e6530000 17 - 18 - root@Lager:~# echo 2 > /sys/devices/platform/i2c@8/cur_master 19 - 20 - root@Lager:~# cat /sys/devices/platform/i2c@8/cur_master 21 - 0 - /i2c@9 22 - 1 - /i2c@e6520000 23 - * 2 - /i2c@e6530000 12 + What: /sys/devices/platform/<i2c-demux-name>/current_master 13 + Date: January 2016 14 + KernelVersion: 4.6 15 + Contact: Wolfram Sang <wsa@the-dreams.de> 16 + Description: 17 + This file selects/shows the active I2C master for a demultiplexed 18 + bus. It uses the <index> value from the file 'available_masters'.
+6 -1
drivers/i2c/busses/i2c-jz4780.c
··· 771 771 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 772 772 &clk_freq); 773 773 if (ret) { 774 - dev_err(&pdev->dev, "clock-frequency not specified in DT"); 774 + dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); 775 775 goto err; 776 776 } 777 777 778 778 i2c->speed = clk_freq / 1000; 779 + if (i2c->speed == 0) { 780 + ret = -EINVAL; 781 + dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); 782 + goto err; 783 + } 779 784 jz4780_i2c_set_speed(i2c); 780 785 781 786 dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed);
+2 -8
drivers/i2c/i2c-core.c
··· 525 525 return 0; 526 526 } 527 527 528 - 529 - /* uevent helps with hotplug: modprobe -q $(MODALIAS) */ 530 528 static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env) 531 529 { 532 - struct i2c_client *client = to_i2c_client(dev); 530 + struct i2c_client *client = to_i2c_client(dev); 533 531 int rc; 534 532 535 533 rc = acpi_device_uevent_modalias(dev, env); 536 534 if (rc != -ENODEV) 537 535 return rc; 538 536 539 - if (add_uevent_var(env, "MODALIAS=%s%s", 540 - I2C_MODULE_PREFIX, client->name)) 541 - return -ENOMEM; 542 - dev_dbg(dev, "uevent\n"); 543 - return 0; 537 + return add_uevent_var(env, "MODALIAS=%s%s", I2C_MODULE_PREFIX, client->name); 544 538 } 545 539 546 540 /* i2c bus recovery routines */
+29 -10
drivers/i2c/muxes/i2c-demux-pinctrl.c
··· 140 140 return i2c_demux_activate_master(priv, new_chan); 141 141 } 142 142 143 - static ssize_t cur_master_show(struct device *dev, struct device_attribute *attr, 144 - char *buf) 143 + static ssize_t available_masters_show(struct device *dev, 144 + struct device_attribute *attr, 145 + char *buf) 145 146 { 146 147 struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); 147 148 int count = 0, i; 148 149 149 150 for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++) 150 - count += scnprintf(buf + count, PAGE_SIZE - count, "%c %d - %s\n", 151 - i == priv->cur_chan ? '*' : ' ', i, 152 - priv->chan[i].parent_np->full_name); 151 + count += scnprintf(buf + count, PAGE_SIZE - count, "%d:%s%c", 152 + i, priv->chan[i].parent_np->full_name, 153 + i == priv->num_chan - 1 ? '\n' : ' '); 153 154 154 155 return count; 155 156 } 157 + static DEVICE_ATTR_RO(available_masters); 156 158 157 - static ssize_t cur_master_store(struct device *dev, struct device_attribute *attr, 158 - const char *buf, size_t count) 159 + static ssize_t current_master_show(struct device *dev, 160 + struct device_attribute *attr, 161 + char *buf) 162 + { 163 + struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); 164 + 165 + return sprintf(buf, "%d\n", priv->cur_chan); 166 + } 167 + 168 + static ssize_t current_master_store(struct device *dev, 169 + struct device_attribute *attr, 170 + const char *buf, size_t count) 159 171 { 160 172 struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); 161 173 unsigned int val; ··· 184 172 185 173 return ret < 0 ? ret : count; 186 174 } 187 - static DEVICE_ATTR_RW(cur_master); 175 + static DEVICE_ATTR_RW(current_master); 188 176 189 177 static int i2c_demux_pinctrl_probe(struct platform_device *pdev) 190 178 { ··· 230 218 /* switch to first parent as active master */ 231 219 i2c_demux_activate_master(priv, 0); 232 220 233 - err = device_create_file(&pdev->dev, &dev_attr_cur_master); 221 + err = device_create_file(&pdev->dev, &dev_attr_available_masters); 234 222 if (err) 235 223 goto err_rollback; 236 224 225 + err = device_create_file(&pdev->dev, &dev_attr_current_master); 226 + if (err) 227 + goto err_rollback_available; 228 + 237 229 return 0; 238 230 231 + err_rollback_available: 232 + device_remove_file(&pdev->dev, &dev_attr_available_masters); 239 233 err_rollback: 240 234 for (j = 0; j < i; j++) { 241 235 of_node_put(priv->chan[j].parent_np); ··· 256 238 struct i2c_demux_pinctrl_priv *priv = platform_get_drvdata(pdev); 257 239 int i; 258 240 259 - device_remove_file(&pdev->dev, &dev_attr_cur_master); 241 + device_remove_file(&pdev->dev, &dev_attr_current_master); 242 + device_remove_file(&pdev->dev, &dev_attr_available_masters); 260 243 261 244 i2c_demux_deactivate_master(priv); 262 245