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

Merge tag 'i2c-for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:
"I2C has mainly cleanups this time and a few driver improvements.

Because a lot of developers were on holidays (including myself) it was
a good timing to apply lots of cleanups which would normally cause
merge conflicts with other floating patches. Extra thanks go to Andi
Shyti who backed me up when I was on a four week hiatus. This is also
the reason that some patches were commited later than ideal"

* tag 'i2c-for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (67 commits)
i2c: at91: Use dev_err_probe() instead of dev_err()
I2C: ali15x3: Do PCI error checks on own line
i2c: Make return value check more accurate and explicit for devm_pinctrl_get()
i2c: designware: Add support for recovery when GPIO need pinctrl
i2c: mlxcpld: Add support for extended transaction length
i2c: mlxcpld: Allow driver to run on ARM64 architecture
i2c: nforce2: Do PCI error check on own line
i2c: sis5595: Do PCI error checks on own line
i2c: qcom-cci: Fix error checking in cci_probe()
i2c: muxes: pca954x: Add regulator support
i2c: muxes: pca954x: Add MAX735x/MAX736x support
dt-bindings: i2c: Add Maxim MAX735x/MAX736x variants
dt-bindings: i2c: pca954x: Correct interrupt support
i2c: pnx: Use devm_platform_get_and_ioremap_resource()
i2c: pxa: Use devm_platform_get_and_ioremap_resource()
i2c: s3c2410: Use devm_platform_get_and_ioremap_resource()
i2c: sh_mobile: Use devm_platform_get_and_ioremap_resource()
i2c: st: Use devm_platform_get_and_ioremap_resource()
i2c: qcom-geni: Convert to devm_platform_ioremap_resource()
i2c: stm32f4: Use devm_platform_get_and_ioremap_resource()
...

+562 -565
+3
Documentation/devicetree/bindings/i2c/cdns,i2c-r1p10.yaml
··· 48 48 default: 16 49 49 enum: [2, 4, 8, 16, 32, 64, 128, 256] 50 50 51 + power-domains: 52 + maxItems: 1 53 + 51 54 required: 52 55 - compatible 53 56 - reg
-82
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt
··· 1 - GPIO-based I2C Arbitration Using a Challenge & Response Mechanism 2 - ================================================================= 3 - This uses GPIO lines and a challenge & response mechanism to arbitrate who is 4 - the master of an I2C bus in a multimaster situation. 5 - 6 - In many cases using GPIOs to arbitrate is not needed and a design can use 7 - the standard I2C multi-master rules. Using GPIOs is generally useful in 8 - the case where there is a device on the bus that has errata and/or bugs 9 - that makes standard multimaster mode not feasible. 10 - 11 - Note that this scheme works well enough but has some downsides: 12 - * It is nonstandard (not using standard I2C multimaster) 13 - * Having two masters on a bus in general makes it relatively hard to debug 14 - problems (hard to tell if i2c issues were caused by one master, another, or 15 - some device on the bus). 16 - 17 - 18 - Algorithm: 19 - 20 - All masters on the bus have a 'bus claim' line which is an output that the 21 - others can see. These are all active low with pull-ups enabled. We'll 22 - describe these lines as: 23 - 24 - - OUR_CLAIM: output from us signaling to other hosts that we want the bus 25 - - THEIR_CLAIMS: output from others signaling that they want the bus 26 - 27 - The basic algorithm is to assert your line when you want the bus, then make 28 - sure that the other side doesn't want it also. A detailed explanation is best 29 - done with an example. 30 - 31 - Let's say we want to claim the bus. We: 32 - 1. Assert OUR_CLAIM. 33 - 2. Waits a little bit for the other sides to notice (slew time, say 10 34 - microseconds). 35 - 3. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we are 36 - done. 37 - 4. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released. 38 - 5. If not, back off, release the claim and wait for a few more milliseconds. 39 - 6. Go back to 1 (until retry time has expired). 40 - 41 - 42 - Required properties: 43 - - compatible: i2c-arb-gpio-challenge 44 - - our-claim-gpio: The GPIO that we use to claim the bus. 45 - - their-claim-gpios: The GPIOs that the other sides use to claim the bus. 46 - Note that some implementations may only support a single other master. 47 - - I2C arbitration bus node. See i2c-arb.txt in this directory. 48 - 49 - Optional properties: 50 - - slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. 51 - - wait-retry-us: we'll attempt another claim after this many microseconds. 52 - Default is 3000 us. 53 - - wait-free-us: we'll give up after this many microseconds. Default is 50000 us. 54 - 55 - 56 - Example: 57 - i2c@12ca0000 { 58 - compatible = "acme,some-i2c-device"; 59 - #address-cells = <1>; 60 - #size-cells = <0>; 61 - }; 62 - 63 - i2c-arbitrator { 64 - compatible = "i2c-arb-gpio-challenge"; 65 - 66 - i2c-parent = <&{/i2c@12CA0000}>; 67 - 68 - our-claim-gpio = <&gpf0 3 1>; 69 - their-claim-gpios = <&gpe0 4 1>; 70 - slew-delay-us = <10>; 71 - wait-retry-us = <3000>; 72 - wait-free-us = <50000>; 73 - 74 - i2c-arb { 75 - #address-cells = <1>; 76 - #size-cells = <0>; 77 - 78 - i2c@52 { 79 - // Normal I2C device 80 - }; 81 - }; 82 - };
+135
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/i2c/i2c-arb-gpio-challenge.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: GPIO-based I2C Arbitration Using a Challenge & Response Mechanism 8 + 9 + maintainers: 10 + - Doug Anderson <dianders@chromium.org> 11 + - Peter Rosin <peda@axentia.se> 12 + 13 + description: | 14 + This uses GPIO lines and a challenge & response mechanism to arbitrate who is 15 + the master of an I2C bus in a multimaster situation. 16 + 17 + In many cases using GPIOs to arbitrate is not needed and a design can use the 18 + standard I2C multi-master rules. Using GPIOs is generally useful in the case 19 + where there is a device on the bus that has errata and/or bugs that makes 20 + standard multimaster mode not feasible. 21 + 22 + Note that this scheme works well enough but has some downsides: 23 + * It is nonstandard (not using standard I2C multimaster) 24 + * Having two masters on a bus in general makes it relatively hard to debug 25 + problems (hard to tell if i2c issues were caused by one master, another, 26 + or some device on the bus). 27 + 28 + Algorithm: 29 + All masters on the bus have a 'bus claim' line which is an output that the 30 + others can see. These are all active low with pull-ups enabled. We'll 31 + describe these lines as: 32 + * OUR_CLAIM: output from us signaling to other hosts that we want the bus 33 + * THEIR_CLAIMS: output from others signaling that they want the bus 34 + 35 + The basic algorithm is to assert your line when you want the bus, then make 36 + sure that the other side doesn't want it also. A detailed explanation is 37 + best done with an example. 38 + 39 + Let's say we want to claim the bus. We: 40 + 1. Assert OUR_CLAIM. 41 + 2. Waits a little bit for the other sides to notice (slew time, say 10 42 + microseconds). 43 + 3. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we 44 + are done. 45 + 4. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released. 46 + 5. If not, back off, release the claim and wait for a few more milliseconds. 47 + 6. Go back to 1 (until retry time has expired). 48 + 49 + properties: 50 + compatible: 51 + const: i2c-arb-gpio-challenge 52 + 53 + i2c-parent: 54 + $ref: /schemas/types.yaml#/definitions/phandle 55 + description: 56 + The I2C bus that this multiplexer's master-side port is connected to. 57 + 58 + our-claim-gpios: 59 + maxItems: 1 60 + description: 61 + The GPIO that we use to claim the bus. 62 + 63 + slew-delay-us: 64 + default: 10 65 + description: 66 + Time to wait for a GPIO to go high. 67 + 68 + their-claim-gpios: 69 + minItems: 1 70 + maxItems: 8 71 + description: 72 + The GPIOs that the other sides use to claim the bus. Note that some 73 + implementations may only support a single other master. 74 + 75 + wait-free-us: 76 + default: 50000 77 + description: 78 + We'll give up after this many microseconds. 79 + 80 + wait-retry-us: 81 + default: 3000 82 + description: 83 + We'll attempt another claim after this many microseconds. 84 + 85 + i2c-arb: 86 + type: object 87 + $ref: /schemas/i2c/i2c-controller.yaml 88 + unevaluatedProperties: false 89 + description: 90 + I2C arbitration bus node. 91 + 92 + required: 93 + - compatible 94 + - i2c-arb 95 + - our-claim-gpios 96 + - their-claim-gpios 97 + 98 + additionalProperties: false 99 + 100 + examples: 101 + - | 102 + #include <dt-bindings/gpio/gpio.h> 103 + #include <dt-bindings/interrupt-controller/irq.h> 104 + 105 + i2c-arbitrator { 106 + compatible = "i2c-arb-gpio-challenge"; 107 + i2c-parent = <&i2c_4>; 108 + 109 + our-claim-gpios = <&gpf0 3 GPIO_ACTIVE_LOW>; 110 + their-claim-gpios = <&gpe0 4 GPIO_ACTIVE_LOW>; 111 + slew-delay-us = <10>; 112 + wait-retry-us = <3000>; 113 + wait-free-us = <50000>; 114 + 115 + i2c-arb { 116 + #address-cells = <1>; 117 + #size-cells = <0>; 118 + 119 + sbs-battery@b { 120 + compatible = "sbs,sbs-battery"; 121 + reg = <0xb>; 122 + sbs,poll-retry-count = <1>; 123 + }; 124 + 125 + embedded-controller@1e { 126 + compatible = "google,cros-ec-i2c"; 127 + reg = <0x1e>; 128 + interrupts = <6 IRQ_TYPE_LEVEL_HIGH>; 129 + interrupt-parent = <&gpx1>; 130 + pinctrl-names = "default"; 131 + pinctrl-0 = <&ec_irq>; 132 + wakeup-source; 133 + }; 134 + }; 135 + };
-35
Documentation/devicetree/bindings/i2c/i2c-arb.txt
··· 1 - Common i2c arbitration bus properties. 2 - 3 - - i2c-arb child node 4 - 5 - Required properties for the i2c-arb child node: 6 - - #address-cells = <1>; 7 - - #size-cells = <0>; 8 - 9 - Optional properties for i2c-arb child node: 10 - - Child nodes conforming to i2c bus binding 11 - 12 - 13 - Example : 14 - 15 - /* 16 - An NXP pca9541 I2C bus master selector at address 0x74 17 - with a NXP pca8574 GPIO expander attached. 18 - */ 19 - 20 - arb@74 { 21 - compatible = "nxp,pca9541"; 22 - reg = <0x74>; 23 - 24 - i2c-arb { 25 - #address-cells = <1>; 26 - #size-cells = <0>; 27 - 28 - gpio@38 { 29 - compatible = "nxp,pca8574"; 30 - reg = <0x38>; 31 - #gpio-cells = <2>; 32 - gpio-controller; 33 - }; 34 - }; 35 - };
+40 -6
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml
··· 4 4 $id: http://devicetree.org/schemas/i2c/i2c-mux-pca954x.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 - title: NXP PCA954x I2C bus switch 7 + title: NXP PCA954x I2C and compatible bus switches 8 8 9 9 maintainers: 10 10 - Laurent Pinchart <laurent.pinchart@ideasonboard.com> 11 11 12 12 description: 13 - The binding supports NXP PCA954x and PCA984x I2C mux/switch devices. 14 - 15 - allOf: 16 - - $ref: /schemas/i2c/i2c-mux.yaml# 13 + The NXP PCA954x and compatible devices are I2C bus 14 + multiplexer/switches that share the same functionality 15 + and register layout. 16 + The devices usually have 4 or 8 child buses, which are 17 + attached to the parent bus by using the SMBus "Send Byte" 18 + command. 17 19 18 20 properties: 19 21 compatible: 20 22 oneOf: 21 23 - enum: 24 + - maxim,max7356 25 + - maxim,max7357 26 + - maxim,max7358 27 + - maxim,max7367 28 + - maxim,max7368 29 + - maxim,max7369 22 30 - nxp,pca9540 23 31 - nxp,pca9542 24 32 - nxp,pca9543 ··· 67 59 description: if present, overrides i2c-mux-idle-disconnect 68 60 $ref: /schemas/mux/mux-controller.yaml#/properties/idle-state 69 61 62 + vdd-supply: 63 + description: A voltage regulator supplying power to the chip. On PCA9846 64 + the regulator supplies power to VDD2 (core logic) and optionally to VDD1. 65 + 70 66 required: 71 67 - compatible 72 68 - reg 69 + 70 + allOf: 71 + - $ref: /schemas/i2c/i2c-mux.yaml# 72 + - if: 73 + not: 74 + properties: 75 + compatible: 76 + contains: 77 + enum: 78 + - maxim,max7367 79 + - maxim,max7369 80 + - nxp,pca9542 81 + - nxp,pca9543 82 + - nxp,pca9544 83 + - nxp,pca9545 84 + then: 85 + properties: 86 + interrupts: false 87 + "#interrupt-cells": false 88 + interrupt-controller: false 73 89 74 90 unevaluatedProperties: false 75 91 ··· 106 74 #size-cells = <0>; 107 75 108 76 i2c-mux@74 { 109 - compatible = "nxp,pca9548"; 77 + compatible = "nxp,pca9545"; 110 78 #address-cells = <1>; 111 79 #size-cells = <0>; 112 80 reg = <0x74>; 81 + 82 + vdd-supply = <&p3v3>; 113 83 114 84 interrupt-parent = <&ipic>; 115 85 interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
-29
Documentation/devicetree/bindings/i2c/nxp,pca9541.txt
··· 1 - * NXP PCA9541 I2C bus master selector 2 - 3 - Required Properties: 4 - 5 - - compatible: Must be "nxp,pca9541" 6 - 7 - - reg: The I2C address of the device. 8 - 9 - The following required properties are defined externally: 10 - 11 - - I2C arbitration bus node. See i2c-arb.txt in this directory. 12 - 13 - 14 - Example: 15 - 16 - i2c-arbitrator@74 { 17 - compatible = "nxp,pca9541"; 18 - reg = <0x74>; 19 - 20 - i2c-arb { 21 - #address-cells = <1>; 22 - #size-cells = <0>; 23 - 24 - eeprom@54 { 25 - compatible = "atmel,24c08"; 26 - reg = <0x54>; 27 - }; 28 - }; 29 - };
+56
Documentation/devicetree/bindings/i2c/nxp,pca9541.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/i2c/nxp,pca9541.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NXP PCA9541 I2C bus master selector 8 + 9 + maintainers: 10 + - Peter Rosin <peda@axentia.se> 11 + 12 + properties: 13 + compatible: 14 + const: nxp,pca9541 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + i2c-arb: 20 + type: object 21 + $ref: /schemas/i2c/i2c-controller.yaml 22 + unevaluatedProperties: false 23 + description: 24 + I2C arbitration bus node. 25 + 26 + required: 27 + - compatible 28 + - reg 29 + - i2c-arb 30 + 31 + additionalProperties: false 32 + 33 + examples: 34 + - | 35 + #include <dt-bindings/gpio/gpio.h> 36 + #include <dt-bindings/interrupt-controller/irq.h> 37 + 38 + i2c { 39 + #address-cells = <1>; 40 + #size-cells = <0>; 41 + 42 + i2c-arbitrator@74 { 43 + compatible = "nxp,pca9541"; 44 + reg = <0x74>; 45 + 46 + i2c-arb { 47 + #address-cells = <1>; 48 + #size-cells = <0>; 49 + 50 + eeprom@54 { 51 + compatible = "atmel,24c08"; 52 + reg = <0x54>; 53 + }; 54 + }; 55 + }; 56 + };
+1 -1
drivers/i2c/busses/Kconfig
··· 1384 1384 1385 1385 config I2C_MLXCPLD 1386 1386 tristate "Mellanox I2C driver" 1387 - depends on X86_64 || COMPILE_TEST 1387 + depends on X86_64 || ARM64 || COMPILE_TEST 1388 1388 help 1389 1389 This exposes the Mellanox platform I2C busses to the linux I2C layer 1390 1390 for X86 based systems.
+6 -5
drivers/i2c/busses/i2c-ali15x3.c
··· 165 165 } 166 166 167 167 if(force_addr) { 168 + int ret; 169 + 168 170 dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n", 169 171 ali15x3_smba); 170 - if (PCIBIOS_SUCCESSFUL != pci_write_config_word(ALI15X3_dev, 171 - SMBBA, 172 - ali15x3_smba)) 172 + ret = pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba); 173 + if (ret != PCIBIOS_SUCCESSFUL) 173 174 goto error; 174 - if (PCIBIOS_SUCCESSFUL != pci_read_config_word(ALI15X3_dev, 175 - SMBBA, &a)) 175 + ret = pci_read_config_word(ALI15X3_dev, SMBBA, &a); 176 + if (ret != PCIBIOS_SUCCESSFUL) 176 177 goto error; 177 178 if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { 178 179 /* make sure it works */
+6 -12
drivers/i2c/busses/i2c-at91-core.c
··· 19 19 #include <linux/io.h> 20 20 #include <linux/module.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_device.h> 23 22 #include <linux/platform_device.h> 24 23 #include <linux/pm_runtime.h> 25 24 #include <linux/pinctrl/consumer.h> ··· 206 207 207 208 dev->dev = &pdev->dev; 208 209 209 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 210 - if (!mem) 211 - return -ENODEV; 210 + dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); 211 + if (IS_ERR(dev->base)) 212 + return PTR_ERR(dev->base); 212 213 phy_addr = mem->start; 213 214 214 215 dev->pdata = at91_twi_get_driver_data(pdev); 215 216 if (!dev->pdata) 216 217 return -ENODEV; 217 - 218 - dev->base = devm_ioremap_resource(&pdev->dev, mem); 219 - if (IS_ERR(dev->base)) 220 - return PTR_ERR(dev->base); 221 218 222 219 dev->irq = platform_get_irq(pdev, 0); 223 220 if (dev->irq < 0) ··· 222 227 platform_set_drvdata(pdev, dev); 223 228 224 229 dev->clk = devm_clk_get(dev->dev, NULL); 225 - if (IS_ERR(dev->clk)) { 226 - dev_err(dev->dev, "no clock defined\n"); 227 - return -ENODEV; 228 - } 230 + if (IS_ERR(dev->clk)) 231 + return dev_err_probe(dev->dev, PTR_ERR(dev->clk), "no clock defined\n"); 232 + 229 233 clk_prepare_enable(dev->clk); 230 234 231 235 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
+5 -2
drivers/i2c/busses/i2c-at91-master.c
··· 23 23 #include <linux/interrupt.h> 24 24 #include <linux/io.h> 25 25 #include <linux/of.h> 26 - #include <linux/of_device.h> 27 26 #include <linux/pinctrl/consumer.h> 28 27 #include <linux/platform_device.h> 29 28 #include <linux/pm_runtime.h> ··· 831 832 struct i2c_bus_recovery_info *rinfo = &dev->rinfo; 832 833 833 834 rinfo->pinctrl = devm_pinctrl_get(&pdev->dev); 834 - if (!rinfo->pinctrl || IS_ERR(rinfo->pinctrl)) { 835 + if (!rinfo->pinctrl) { 836 + dev_info(dev->dev, "pinctrl unavailable, bus recovery not supported\n"); 837 + return 0; 838 + } 839 + if (IS_ERR(rinfo->pinctrl)) { 835 840 dev_info(dev->dev, "can't get pinctrl, bus recovery not supported\n"); 836 841 return PTR_ERR(rinfo->pinctrl); 837 842 }
+3 -12
drivers/i2c/busses/i2c-au1550.c
··· 342 342 i2c_au1550_disable(priv); 343 343 } 344 344 345 - #ifdef CONFIG_PM 346 345 static int i2c_au1550_suspend(struct device *dev) 347 346 { 348 347 struct i2c_au1550_data *priv = dev_get_drvdata(dev); ··· 360 361 return 0; 361 362 } 362 363 363 - static const struct dev_pm_ops i2c_au1550_pmops = { 364 - .suspend = i2c_au1550_suspend, 365 - .resume = i2c_au1550_resume, 366 - }; 367 - 368 - #define AU1XPSC_SMBUS_PMOPS (&i2c_au1550_pmops) 369 - 370 - #else 371 - #define AU1XPSC_SMBUS_PMOPS NULL 372 - #endif 364 + static DEFINE_SIMPLE_DEV_PM_OPS(i2c_au1550_pmops, 365 + i2c_au1550_suspend, i2c_au1550_resume); 373 366 374 367 static struct platform_driver au1xpsc_smbus_driver = { 375 368 .driver = { 376 369 .name = "au1xpsc_smbus", 377 - .pm = AU1XPSC_SMBUS_PMOPS, 370 + .pm = pm_sleep_ptr(&i2c_au1550_pmops), 378 371 }, 379 372 .probe = i2c_au1550_probe, 380 373 .remove_new = i2c_au1550_remove,
+4 -16
drivers/i2c/busses/i2c-bcm-iproc.c
··· 7 7 #include <linux/io.h> 8 8 #include <linux/kernel.h> 9 9 #include <linux/module.h> 10 - #include <linux/of_device.h> 10 + #include <linux/of.h> 11 11 #include <linux/platform_device.h> 12 12 #include <linux/slab.h> 13 13 ··· 1029 1029 int irq, ret = 0; 1030 1030 struct bcm_iproc_i2c_dev *iproc_i2c; 1031 1031 struct i2c_adapter *adap; 1032 - struct resource *res; 1033 1032 1034 1033 iproc_i2c = devm_kzalloc(&pdev->dev, sizeof(*iproc_i2c), 1035 1034 GFP_KERNEL); ··· 1041 1042 (enum bcm_iproc_i2c_type)of_device_get_match_data(&pdev->dev); 1042 1043 init_completion(&iproc_i2c->done); 1043 1044 1044 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1045 - iproc_i2c->base = devm_ioremap_resource(iproc_i2c->device, res); 1045 + iproc_i2c->base = devm_platform_ioremap_resource(pdev, 0); 1046 1046 if (IS_ERR(iproc_i2c->base)) 1047 1047 return PTR_ERR(iproc_i2c->base); 1048 1048 1049 1049 if (iproc_i2c->type == IPROC_I2C_NIC) { 1050 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1051 - iproc_i2c->idm_base = devm_ioremap_resource(iproc_i2c->device, 1052 - res); 1050 + iproc_i2c->idm_base = devm_platform_ioremap_resource(pdev, 1); 1053 1051 if (IS_ERR(iproc_i2c->idm_base)) 1054 1052 return PTR_ERR(iproc_i2c->idm_base); 1055 1053 ··· 1124 1128 bcm_iproc_i2c_enable_disable(iproc_i2c, false); 1125 1129 } 1126 1130 1127 - #ifdef CONFIG_PM_SLEEP 1128 - 1129 1131 static int bcm_iproc_i2c_suspend(struct device *dev) 1130 1132 { 1131 1133 struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev); ··· 1173 1179 .suspend_late = &bcm_iproc_i2c_suspend, 1174 1180 .resume_early = &bcm_iproc_i2c_resume 1175 1181 }; 1176 - 1177 - #define BCM_IPROC_I2C_PM_OPS (&bcm_iproc_i2c_pm_ops) 1178 - #else 1179 - #define BCM_IPROC_I2C_PM_OPS NULL 1180 - #endif /* CONFIG_PM_SLEEP */ 1181 - 1182 1182 1183 1183 static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave) 1184 1184 { ··· 1246 1258 .driver = { 1247 1259 .name = "bcm-iproc-i2c", 1248 1260 .of_match_table = bcm_iproc_i2c_of_match, 1249 - .pm = BCM_IPROC_I2C_PM_OPS, 1261 + .pm = pm_sleep_ptr(&bcm_iproc_i2c_pm_ops), 1250 1262 }, 1251 1263 .probe = bcm_iproc_i2c_probe, 1252 1264 .remove_new = bcm_iproc_i2c_remove,
+7 -9
drivers/i2c/busses/i2c-bcm2835.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/io.h> 14 14 #include <linux/module.h> 15 - #include <linux/of_device.h> 15 + #include <linux/of.h> 16 16 #include <linux/platform_device.h> 17 17 #include <linux/slab.h> 18 18 ··· 430 430 431 431 i2c_dev->bus_clk = bcm2835_i2c_register_div(&pdev->dev, mclk, i2c_dev); 432 432 433 - if (IS_ERR(i2c_dev->bus_clk)) { 434 - dev_err(&pdev->dev, "Could not register clock\n"); 435 - return PTR_ERR(i2c_dev->bus_clk); 436 - } 433 + if (IS_ERR(i2c_dev->bus_clk)) 434 + return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->bus_clk), 435 + "Could not register clock\n"); 437 436 438 437 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 439 438 &bus_clk_rate); ··· 443 444 } 444 445 445 446 ret = clk_set_rate_exclusive(i2c_dev->bus_clk, bus_clk_rate); 446 - if (ret < 0) { 447 - dev_err(&pdev->dev, "Could not set clock frequency\n"); 448 - return ret; 449 - } 447 + if (ret < 0) 448 + return dev_err_probe(&pdev->dev, ret, 449 + "Could not set clock frequency\n"); 450 450 451 451 ret = clk_prepare_enable(i2c_dev->bus_clk); 452 452 if (ret) {
+9 -18
drivers/i2c/busses/i2c-brcmstb.c
··· 594 594 595 595 static int brcmstb_i2c_probe(struct platform_device *pdev) 596 596 { 597 - int rc = 0; 598 597 struct brcmstb_i2c_dev *dev; 599 598 struct i2c_adapter *adap; 600 - struct resource *iomem; 601 599 const char *int_name; 600 + int rc; 602 601 603 602 /* Allocate memory for private data structure */ 604 603 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); ··· 613 614 init_completion(&dev->done); 614 615 615 616 /* Map hardware registers */ 616 - iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 617 - dev->base = devm_ioremap_resource(dev->device, iomem); 618 - if (IS_ERR(dev->base)) { 619 - rc = -ENOMEM; 620 - goto probe_errorout; 621 - } 617 + dev->base = devm_platform_ioremap_resource(pdev, 0); 618 + if (IS_ERR(dev->base)) 619 + return PTR_ERR(dev->base); 622 620 623 621 if (of_device_is_compatible(dev->device->of_node, 624 622 "brcm,bcm2711-hdmi-i2c")) { 625 623 rc = bcm2711_release_bsc(dev); 626 624 if (rc) 627 - goto probe_errorout; 625 + return rc; 628 626 } 629 627 630 628 rc = of_property_read_string(dev->device->of_node, "interrupt-names", ··· 674 678 adap->dev.of_node = pdev->dev.of_node; 675 679 rc = i2c_add_adapter(adap); 676 680 if (rc) 677 - goto probe_errorout; 681 + return rc; 678 682 679 683 dev_info(dev->device, "%s@%dhz registered in %s mode\n", 680 684 int_name ? int_name : " ", dev->clk_freq_hz, 681 685 (dev->irq >= 0) ? "interrupt" : "polling"); 682 686 683 687 return 0; 684 - 685 - probe_errorout: 686 - return rc; 687 688 } 688 689 689 690 static void brcmstb_i2c_remove(struct platform_device *pdev) ··· 690 697 i2c_del_adapter(&dev->adapter); 691 698 } 692 699 693 - #ifdef CONFIG_PM_SLEEP 694 700 static int brcmstb_i2c_suspend(struct device *dev) 695 701 { 696 702 struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev); ··· 707 715 708 716 return 0; 709 717 } 710 - #endif 711 718 712 - static SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend, 713 - brcmstb_i2c_resume); 719 + static DEFINE_SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend, 720 + brcmstb_i2c_resume); 714 721 715 722 static const struct of_device_id brcmstb_i2c_of_match[] = { 716 723 {.compatible = "brcm,brcmstb-i2c"}, ··· 723 732 .driver = { 724 733 .name = "brcmstb-i2c", 725 734 .of_match_table = brcmstb_i2c_of_match, 726 - .pm = &brcmstb_i2c_pm, 735 + .pm = pm_sleep_ptr(&brcmstb_i2c_pm), 727 736 }, 728 737 .probe = brcmstb_i2c_probe, 729 738 .remove_new = brcmstb_i2c_remove,
+2 -2
drivers/i2c/busses/i2c-cpm.c
··· 26 26 #include <linux/i2c.h> 27 27 #include <linux/io.h> 28 28 #include <linux/dma-mapping.h> 29 + #include <linux/of.h> 29 30 #include <linux/of_address.h> 30 - #include <linux/of_device.h> 31 31 #include <linux/of_irq.h> 32 - #include <linux/of_platform.h> 32 + #include <linux/platform_device.h> 33 33 #include <sysdev/fsl_soc.h> 34 34 #include <asm/cpm.h> 35 35
+5 -11
drivers/i2c/busses/i2c-davinci.c
··· 25 25 #include <linux/slab.h> 26 26 #include <linux/cpufreq.h> 27 27 #include <linux/gpio/consumer.h> 28 - #include <linux/of_device.h> 28 + #include <linux/of.h> 29 29 #include <linux/platform_data/i2c-davinci.h> 30 30 #include <linux/pm_runtime.h> 31 31 ··· 765 765 766 766 irq = platform_get_irq(pdev, 0); 767 767 if (irq < 0) 768 - return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n"); 768 + return irq; 769 769 770 770 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 771 771 if (!dev) ··· 902 902 pm_runtime_disable(dev->dev); 903 903 } 904 904 905 - #ifdef CONFIG_PM 906 905 static int davinci_i2c_suspend(struct device *dev) 907 906 { 908 907 struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev); ··· 925 926 static const struct dev_pm_ops davinci_i2c_pm = { 926 927 .suspend = davinci_i2c_suspend, 927 928 .resume = davinci_i2c_resume, 928 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 929 - pm_runtime_force_resume) 929 + NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 930 + pm_runtime_force_resume) 930 931 }; 931 - 932 - #define davinci_i2c_pm_ops (&davinci_i2c_pm) 933 - #else 934 - #define davinci_i2c_pm_ops NULL 935 - #endif 936 932 937 933 static const struct platform_device_id davinci_i2c_driver_ids[] = { 938 934 { .name = "i2c_davinci", }, ··· 941 947 .id_table = davinci_i2c_driver_ids, 942 948 .driver = { 943 949 .name = "i2c_davinci", 944 - .pm = davinci_i2c_pm_ops, 950 + .pm = pm_sleep_ptr(&davinci_i2c_pm), 945 951 .of_match_table = davinci_i2c_of_match, 946 952 }, 947 953 };
+12
drivers/i2c/busses/i2c-designware-master.c
··· 17 17 #include <linux/interrupt.h> 18 18 #include <linux/io.h> 19 19 #include <linux/module.h> 20 + #include <linux/pinctrl/consumer.h> 20 21 #include <linux/pm_runtime.h> 21 22 #include <linux/regmap.h> 22 23 #include <linux/reset.h> ··· 917 916 if (IS_ERR(gpio)) 918 917 return PTR_ERR(gpio); 919 918 rinfo->sda_gpiod = gpio; 919 + 920 + rinfo->pinctrl = devm_pinctrl_get(dev->dev); 921 + if (IS_ERR(rinfo->pinctrl)) { 922 + if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER) 923 + return PTR_ERR(rinfo->pinctrl); 924 + 925 + rinfo->pinctrl = NULL; 926 + dev_err(dev->dev, "getting pinctrl info failed: bus recovery might not work\n"); 927 + } else if (!rinfo->pinctrl) { 928 + dev_dbg(dev->dev, "pinctrl is disabled, bus recovery might not work\n"); 929 + } 920 930 921 931 rinfo->recover_bus = i2c_generic_scl_recovery; 922 932 rinfo->prepare_recovery = i2c_dw_prepare_recovery;
+6 -16
drivers/i2c/busses/i2c-designware-platdrv.c
··· 418 418 reset_control_assert(dev->rst); 419 419 } 420 420 421 - #ifdef CONFIG_PM_SLEEP 422 421 static int dw_i2c_plat_prepare(struct device *dev) 423 422 { 424 423 /* ··· 428 429 */ 429 430 return !has_acpi_companion(dev); 430 431 } 431 - #else 432 - #define dw_i2c_plat_prepare NULL 433 - #endif 434 432 435 - #ifdef CONFIG_PM 436 433 static int dw_i2c_plat_runtime_suspend(struct device *dev) 437 434 { 438 435 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); ··· 442 447 return 0; 443 448 } 444 449 445 - static int __maybe_unused dw_i2c_plat_suspend(struct device *dev) 450 + static int dw_i2c_plat_suspend(struct device *dev) 446 451 { 447 452 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 448 453 ··· 463 468 return 0; 464 469 } 465 470 466 - static int __maybe_unused dw_i2c_plat_resume(struct device *dev) 471 + static int dw_i2c_plat_resume(struct device *dev) 467 472 { 468 473 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 469 474 ··· 474 479 } 475 480 476 481 static const struct dev_pm_ops dw_i2c_dev_pm_ops = { 477 - .prepare = dw_i2c_plat_prepare, 478 - SET_LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) 479 - SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL) 482 + .prepare = pm_sleep_ptr(dw_i2c_plat_prepare), 483 + LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) 484 + RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL) 480 485 }; 481 - 482 - #define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops) 483 - #else 484 - #define DW_I2C_DEV_PMOPS NULL 485 - #endif 486 486 487 487 /* Work with hotplug and coldplug */ 488 488 MODULE_ALIAS("platform:i2c_designware"); ··· 489 499 .name = "i2c_designware", 490 500 .of_match_table = of_match_ptr(dw_i2c_of_match), 491 501 .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match), 492 - .pm = DW_I2C_DEV_PMOPS, 502 + .pm = pm_ptr(&dw_i2c_dev_pm_ops), 493 503 }, 494 504 }; 495 505
+2 -4
drivers/i2c/busses/i2c-dln2.c
··· 218 218 219 219 /* initialize the i2c interface */ 220 220 ret = dln2_i2c_enable(dln2, true); 221 - if (ret < 0) { 222 - dev_err(dev, "failed to initialize adapter: %d\n", ret); 223 - return ret; 224 - } 221 + if (ret < 0) 222 + return dev_err_probe(dev, ret, "failed to initialize adapter\n"); 225 223 226 224 /* and finally attach to i2c layer */ 227 225 ret = i2c_add_adapter(&dln2->adapter);
+1 -1
drivers/i2c/busses/i2c-emev2.c
··· 16 16 #include <linux/io.h> 17 17 #include <linux/kernel.h> 18 18 #include <linux/module.h> 19 - #include <linux/of_device.h> 19 + #include <linux/of.h> 20 20 #include <linux/platform_device.h> 21 21 #include <linux/sched.h> 22 22
+4 -8
drivers/i2c/busses/i2c-exynos5.c
··· 18 18 #include <linux/clk.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/io.h> 21 - #include <linux/of_address.h> 22 - #include <linux/of_device.h> 23 - #include <linux/of_irq.h> 21 + #include <linux/of.h> 24 22 #include <linux/spinlock.h> 25 23 26 24 /* ··· 890 892 clk_unprepare(i2c->pclk); 891 893 } 892 894 893 - #ifdef CONFIG_PM_SLEEP 894 895 static int exynos5_i2c_suspend_noirq(struct device *dev) 895 896 { 896 897 struct exynos5_i2c *i2c = dev_get_drvdata(dev); ··· 931 934 clk_disable_unprepare(i2c->pclk); 932 935 return ret; 933 936 } 934 - #endif 935 937 936 938 static const struct dev_pm_ops exynos5_i2c_dev_pm_ops = { 937 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(exynos5_i2c_suspend_noirq, 938 - exynos5_i2c_resume_noirq) 939 + NOIRQ_SYSTEM_SLEEP_PM_OPS(exynos5_i2c_suspend_noirq, 940 + exynos5_i2c_resume_noirq) 939 941 }; 940 942 941 943 static struct platform_driver exynos5_i2c_driver = { ··· 942 946 .remove_new = exynos5_i2c_remove, 943 947 .driver = { 944 948 .name = "exynos5-hsi2c", 945 - .pm = &exynos5_i2c_dev_pm_ops, 949 + .pm = pm_sleep_ptr(&exynos5_i2c_dev_pm_ops), 946 950 .of_match_table = exynos5_i2c_match, 947 951 }, 948 952 };
+2 -1
drivers/i2c/busses/i2c-gxp.c
··· 4 4 #include <linux/err.h> 5 5 #include <linux/io.h> 6 6 #include <linux/i2c.h> 7 + #include <linux/mod_devicetable.h> 7 8 #include <linux/module.h> 8 - #include <linux/of_device.h> 9 + #include <linux/platform_device.h> 9 10 #include <linux/regmap.h> 10 11 #include <linux/mfd/syscon.h> 11 12
+4 -8
drivers/i2c/busses/i2c-hisi.c
··· 470 470 hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL); 471 471 472 472 ret = devm_request_irq(dev, ctlr->irq, hisi_i2c_irq, 0, "hisi-i2c", ctlr); 473 - if (ret) { 474 - dev_err(dev, "failed to request irq handler, ret = %d\n", ret); 475 - return ret; 476 - } 473 + if (ret) 474 + return dev_err_probe(dev, ret, "failed to request irq handler\n"); 477 475 478 476 ctlr->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); 479 477 if (IS_ERR_OR_NULL(ctlr->clk)) { 480 478 ret = device_property_read_u64(dev, "clk_rate", &clk_rate_hz); 481 - if (ret) { 482 - dev_err(dev, "failed to get clock frequency, ret = %d\n", ret); 483 - return ret; 484 - } 479 + if (ret) 480 + return dev_err_probe(dev, ret, "failed to get clock frequency\n"); 485 481 } else { 486 482 clk_rate_hz = clk_get_rate(ctlr->clk); 487 483 }
+4 -6
drivers/i2c/busses/i2c-hix5hd2.c
··· 475 475 pm_runtime_set_suspended(priv->dev); 476 476 } 477 477 478 - #ifdef CONFIG_PM 479 478 static int hix5hd2_i2c_runtime_suspend(struct device *dev) 480 479 { 481 480 struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev); ··· 493 494 494 495 return 0; 495 496 } 496 - #endif 497 497 498 498 static const struct dev_pm_ops hix5hd2_i2c_pm_ops = { 499 - SET_RUNTIME_PM_OPS(hix5hd2_i2c_runtime_suspend, 500 - hix5hd2_i2c_runtime_resume, 501 - NULL) 499 + RUNTIME_PM_OPS(hix5hd2_i2c_runtime_suspend, 500 + hix5hd2_i2c_runtime_resume, 501 + NULL) 502 502 }; 503 503 504 504 static const struct of_device_id hix5hd2_i2c_match[] = { ··· 511 513 .remove_new = hix5hd2_i2c_remove, 512 514 .driver = { 513 515 .name = "hix5hd2-i2c", 514 - .pm = &hix5hd2_i2c_pm_ops, 516 + .pm = pm_ptr(&hix5hd2_i2c_pm_ops), 515 517 .of_match_table = hix5hd2_i2c_match, 516 518 }, 517 519 };
+2 -4
drivers/i2c/busses/i2c-i801.c
··· 1808 1808 pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); 1809 1809 } 1810 1810 1811 - #ifdef CONFIG_PM_SLEEP 1812 1811 static int i801_suspend(struct device *dev) 1813 1812 { 1814 1813 struct i801_priv *priv = dev_get_drvdata(dev); ··· 1826 1827 1827 1828 return 0; 1828 1829 } 1829 - #endif 1830 1830 1831 - static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume); 1831 + static DEFINE_SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume); 1832 1832 1833 1833 static struct pci_driver i801_driver = { 1834 1834 .name = DRV_NAME, ··· 1836 1838 .remove = i801_remove, 1837 1839 .shutdown = i801_shutdown, 1838 1840 .driver = { 1839 - .pm = &i801_pm_ops, 1841 + .pm = pm_sleep_ptr(&i801_pm_ops), 1840 1842 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1841 1843 }, 1842 1844 };
+2 -1
drivers/i2c/busses/i2c-ibm_iic.c
··· 37 37 #include <asm/irq.h> 38 38 #include <linux/io.h> 39 39 #include <linux/i2c.h> 40 + #include <linux/of.h> 40 41 #include <linux/of_address.h> 41 42 #include <linux/of_irq.h> 42 - #include <linux/of_platform.h> 43 + #include <linux/platform_device.h> 43 44 44 45 #include "i2c-ibm_iic.h" 45 46
+3 -7
drivers/i2c/busses/i2c-img-scb.c
··· 1454 1454 return 0; 1455 1455 } 1456 1456 1457 - #ifdef CONFIG_PM_SLEEP 1458 1457 static int img_i2c_suspend(struct device *dev) 1459 1458 { 1460 1459 struct img_i2c *i2c = dev_get_drvdata(dev); ··· 1481 1482 1482 1483 return 0; 1483 1484 } 1484 - #endif /* CONFIG_PM_SLEEP */ 1485 1485 1486 1486 static const struct dev_pm_ops img_i2c_pm = { 1487 - SET_RUNTIME_PM_OPS(img_i2c_runtime_suspend, 1488 - img_i2c_runtime_resume, 1489 - NULL) 1490 - SET_SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume) 1487 + RUNTIME_PM_OPS(img_i2c_runtime_suspend, img_i2c_runtime_resume, NULL) 1488 + SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume) 1491 1489 }; 1492 1490 1493 1491 static const struct of_device_id img_scb_i2c_match[] = { ··· 1497 1501 .driver = { 1498 1502 .name = "img-i2c-scb", 1499 1503 .of_match_table = img_scb_i2c_match, 1500 - .pm = &img_i2c_pm, 1504 + .pm = pm_ptr(&img_i2c_pm), 1501 1505 }, 1502 1506 .probe = img_i2c_probe, 1503 1507 .remove_new = img_i2c_remove,
+8 -15
drivers/i2c/busses/i2c-imx-lpi2c.c
··· 17 17 #include <linux/kernel.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_device.h> 21 20 #include <linux/pinctrl/consumer.h> 22 21 #include <linux/platform_device.h> 23 22 #include <linux/pm_runtime.h> ··· 516 517 temp = readl(lpi2c_imx->base + LPI2C_MSR); 517 518 temp &= enabled; 518 519 519 - if (temp & MSR_RDF) 520 - lpi2c_imx_read_rxfifo(lpi2c_imx); 521 - 522 - if (temp & MSR_TDF) 523 - lpi2c_imx_write_txfifo(lpi2c_imx); 524 - 525 520 if (temp & MSR_NDF) 526 521 complete(&lpi2c_imx->complete); 522 + else if (temp & MSR_RDF) 523 + lpi2c_imx_read_rxfifo(lpi2c_imx); 524 + else if (temp & MSR_TDF) 525 + lpi2c_imx_write_txfifo(lpi2c_imx); 527 526 528 527 return IRQ_HANDLED; 529 528 } ··· 569 572 sizeof(lpi2c_imx->adapter.name)); 570 573 571 574 ret = devm_clk_bulk_get_all(&pdev->dev, &lpi2c_imx->clks); 572 - if (ret < 0) { 573 - dev_err(&pdev->dev, "can't get I2C peripheral clock, ret=%d\n", ret); 574 - return ret; 575 - } 575 + if (ret < 0) 576 + return dev_err_probe(&pdev->dev, ret, "can't get I2C peripheral clock\n"); 576 577 lpi2c_imx->num_clks = ret; 577 578 578 579 ret = of_property_read_u32(pdev->dev.of_node, ··· 580 585 581 586 ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0, 582 587 pdev->name, lpi2c_imx); 583 - if (ret) { 584 - dev_err(&pdev->dev, "can't claim irq %d\n", irq); 585 - return ret; 586 - } 588 + if (ret) 589 + return dev_err_probe(&pdev->dev, ret, "can't claim irq %d\n", irq); 587 590 588 591 i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx); 589 592 platform_set_drvdata(pdev, lpi2c_imx);
+6 -4
drivers/i2c/busses/i2c-imx.c
··· 41 41 #include <linux/hrtimer.h> 42 42 #include <linux/module.h> 43 43 #include <linux/of.h> 44 - #include <linux/of_device.h> 45 44 #include <linux/of_dma.h> 46 45 #include <linux/pinctrl/consumer.h> 47 46 #include <linux/platform_data/i2c-imx.h> ··· 1388 1389 struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo; 1389 1390 1390 1391 i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev); 1391 - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) { 1392 + if (!i2c_imx->pinctrl) { 1393 + dev_info(&pdev->dev, "pinctrl unavailable, bus recovery not supported\n"); 1394 + return 0; 1395 + } 1396 + if (IS_ERR(i2c_imx->pinctrl)) { 1392 1397 dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); 1393 1398 return PTR_ERR(i2c_imx->pinctrl); 1394 1399 } ··· 1509 1506 goto rpm_disable; 1510 1507 1511 1508 /* Request IRQ */ 1512 - ret = request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED, 1513 - pdev->name, i2c_imx); 1509 + ret = request_irq(irq, i2c_imx_isr, IRQF_SHARED, pdev->name, i2c_imx); 1514 1510 if (ret) { 1515 1511 dev_err(&pdev->dev, "can't claim irq %d\n", irq); 1516 1512 goto rpm_disable;
+1 -1
drivers/i2c/busses/i2c-jz4780.c
··· 18 18 #include <linux/io.h> 19 19 #include <linux/kernel.h> 20 20 #include <linux/module.h> 21 - #include <linux/of_device.h> 21 + #include <linux/of.h> 22 22 #include <linux/platform_device.h> 23 23 #include <linux/sched.h> 24 24 #include <linux/slab.h>
+8 -11
drivers/i2c/busses/i2c-kempld.c
··· 350 350 i2c_del_adapter(&i2c->adap); 351 351 } 352 352 353 - #ifdef CONFIG_PM 354 - static int kempld_i2c_suspend(struct platform_device *pdev, pm_message_t state) 353 + static int kempld_i2c_suspend(struct device *dev) 355 354 { 356 - struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); 355 + struct kempld_i2c_data *i2c = dev_get_drvdata(dev); 357 356 struct kempld_device_data *pld = i2c->pld; 358 357 u8 ctrl; 359 358 ··· 365 366 return 0; 366 367 } 367 368 368 - static int kempld_i2c_resume(struct platform_device *pdev) 369 + static int kempld_i2c_resume(struct device *dev) 369 370 { 370 - struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); 371 + struct kempld_i2c_data *i2c = dev_get_drvdata(dev); 371 372 struct kempld_device_data *pld = i2c->pld; 372 373 373 374 kempld_get_mutex(pld); ··· 376 377 377 378 return 0; 378 379 } 379 - #else 380 - #define kempld_i2c_suspend NULL 381 - #define kempld_i2c_resume NULL 382 - #endif 380 + 381 + static DEFINE_SIMPLE_DEV_PM_OPS(kempld_i2c_pm_ops, 382 + kempld_i2c_suspend, kempld_i2c_resume); 383 383 384 384 static struct platform_driver kempld_i2c_driver = { 385 385 .driver = { 386 386 .name = "kempld-i2c", 387 + .pm = pm_sleep_ptr(&kempld_i2c_pm_ops), 387 388 }, 388 389 .probe = kempld_i2c_probe, 389 390 .remove_new = kempld_i2c_remove, 390 - .suspend = kempld_i2c_suspend, 391 - .resume = kempld_i2c_resume, 392 391 }; 393 392 394 393 module_platform_driver(kempld_i2c_driver);
+1 -8
drivers/i2c/busses/i2c-lpc2k.c
··· 20 20 #include <linux/kernel.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 - #include <linux/of_device.h> 24 23 #include <linux/platform_device.h> 25 24 #include <linux/sched.h> 26 25 #include <linux/time.h> ··· 430 431 i2c_del_adapter(&i2c->adap); 431 432 } 432 433 433 - #ifdef CONFIG_PM 434 434 static int i2c_lpc2k_suspend(struct device *dev) 435 435 { 436 436 struct lpc2k_i2c *i2c = dev_get_drvdata(dev); ··· 454 456 .resume_noirq = i2c_lpc2k_resume, 455 457 }; 456 458 457 - #define I2C_LPC2K_DEV_PM_OPS (&i2c_lpc2k_dev_pm_ops) 458 - #else 459 - #define I2C_LPC2K_DEV_PM_OPS NULL 460 - #endif 461 - 462 459 static const struct of_device_id lpc2k_i2c_match[] = { 463 460 { .compatible = "nxp,lpc1788-i2c" }, 464 461 {}, ··· 465 472 .remove_new = i2c_lpc2k_remove, 466 473 .driver = { 467 474 .name = "lpc2k-i2c", 468 - .pm = I2C_LPC2K_DEV_PM_OPS, 475 + .pm = pm_sleep_ptr(&i2c_lpc2k_dev_pm_ops), 469 476 .of_match_table = lpc2k_i2c_match, 470 477 }, 471 478 };
-1
drivers/i2c/busses/i2c-meson.c
··· 15 15 #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 17 #include <linux/of.h> 18 - #include <linux/of_device.h> 19 18 #include <linux/platform_device.h> 20 19 #include <linux/types.h> 21 20
+2 -3
drivers/i2c/busses/i2c-microchip-corei2c.c
··· 378 378 return PTR_ERR(idev->base); 379 379 380 380 irq = platform_get_irq(pdev, 0); 381 - if (irq <= 0) 382 - return dev_err_probe(&pdev->dev, -ENXIO, 383 - "invalid IRQ %d for I2C controller\n", irq); 381 + if (irq < 0) 382 + return irq; 384 383 385 384 idev->i2c_clk = devm_clk_get(&pdev->dev, NULL); 386 385 if (IS_ERR(idev->i2c_clk))
+19 -41
drivers/i2c/busses/i2c-mlxbf.c
··· 15 15 #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 17 #include <linux/mutex.h> 18 - #include <linux/of_device.h> 18 + #include <linux/of.h> 19 19 #include <linux/platform_device.h> 20 20 #include <linux/string.h> 21 21 ··· 1080 1080 if (!tmp_res) 1081 1081 return -ENOMEM; 1082 1082 1083 - tmp_res->params = platform_get_resource(pdev, IORESOURCE_MEM, type); 1084 - if (!tmp_res->params) { 1085 - devm_kfree(dev, tmp_res); 1086 - return -EIO; 1087 - } 1088 - 1089 - tmp_res->io = devm_ioremap_resource(dev, tmp_res->params); 1083 + tmp_res->io = devm_platform_get_and_ioremap_resource(pdev, type, &tmp_res->params); 1090 1084 if (IS_ERR(tmp_res->io)) { 1091 1085 devm_kfree(dev, tmp_res); 1092 1086 return PTR_ERR(tmp_res->io); ··· 2317 2323 2318 2324 ret = mlxbf_i2c_init_resource(pdev, &priv->smbus, 2319 2325 MLXBF_I2C_SMBUS_RES); 2320 - if (ret < 0) { 2321 - dev_err(dev, "Cannot fetch smbus resource info"); 2322 - return ret; 2323 - } 2326 + if (ret < 0) 2327 + return dev_err_probe(dev, ret, "Cannot fetch smbus resource info"); 2324 2328 2325 2329 priv->timer->io = priv->smbus->io; 2326 2330 priv->mst->io = priv->smbus->io + MLXBF_I2C_MST_ADDR_OFFSET; ··· 2326 2334 } else { 2327 2335 ret = mlxbf_i2c_init_resource(pdev, &priv->timer, 2328 2336 MLXBF_I2C_SMBUS_TIMER_RES); 2329 - if (ret < 0) { 2330 - dev_err(dev, "Cannot fetch timer resource info"); 2331 - return ret; 2332 - } 2337 + if (ret < 0) 2338 + return dev_err_probe(dev, ret, "Cannot fetch timer resource info"); 2333 2339 2334 2340 ret = mlxbf_i2c_init_resource(pdev, &priv->mst, 2335 2341 MLXBF_I2C_SMBUS_MST_RES); 2336 - if (ret < 0) { 2337 - dev_err(dev, "Cannot fetch master resource info"); 2338 - return ret; 2339 - } 2342 + if (ret < 0) 2343 + return dev_err_probe(dev, ret, "Cannot fetch master resource info"); 2340 2344 2341 2345 ret = mlxbf_i2c_init_resource(pdev, &priv->slv, 2342 2346 MLXBF_I2C_SMBUS_SLV_RES); 2343 - if (ret < 0) { 2344 - dev_err(dev, "Cannot fetch slave resource info"); 2345 - return ret; 2346 - } 2347 + if (ret < 0) 2348 + return dev_err_probe(dev, ret, "Cannot fetch slave resource info"); 2347 2349 } 2348 2350 2349 2351 ret = mlxbf_i2c_init_resource(pdev, &priv->mst_cause, 2350 2352 MLXBF_I2C_MST_CAUSE_RES); 2351 - if (ret < 0) { 2352 - dev_err(dev, "Cannot fetch cause master resource info"); 2353 - return ret; 2354 - } 2353 + if (ret < 0) 2354 + return dev_err_probe(dev, ret, "Cannot fetch cause master resource info"); 2355 2355 2356 2356 ret = mlxbf_i2c_init_resource(pdev, &priv->slv_cause, 2357 2357 MLXBF_I2C_SLV_CAUSE_RES); 2358 - if (ret < 0) { 2359 - dev_err(dev, "Cannot fetch cause slave resource info"); 2360 - return ret; 2361 - } 2358 + if (ret < 0) 2359 + return dev_err_probe(dev, ret, "Cannot fetch cause slave resource info"); 2362 2360 2363 2361 adap = &priv->adap; 2364 2362 adap->owner = THIS_MODULE; ··· 2379 2397 * does not really hurt, then keep the code as is. 2380 2398 */ 2381 2399 ret = mlxbf_i2c_init_master(pdev, priv); 2382 - if (ret < 0) { 2383 - dev_err(dev, "failed to initialize smbus master %d", 2384 - priv->bus); 2385 - return ret; 2386 - } 2400 + if (ret < 0) 2401 + return dev_err_probe(dev, ret, "failed to initialize smbus master %d", 2402 + priv->bus); 2387 2403 2388 2404 mlxbf_i2c_init_timings(pdev, priv); 2389 2405 ··· 2393 2413 ret = devm_request_irq(dev, irq, mlxbf_i2c_irq, 2394 2414 IRQF_SHARED | IRQF_PROBE_SHARED, 2395 2415 dev_name(dev), priv); 2396 - if (ret < 0) { 2397 - dev_err(dev, "Cannot get irq %d\n", irq); 2398 - return ret; 2399 - } 2416 + if (ret < 0) 2417 + return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq); 2400 2418 2401 2419 priv->irq = irq; 2402 2420
+10
drivers/i2c/busses/i2c-mlxcpld.c
··· 22 22 #define MLXCPLD_I2C_BUS_NUM 1 23 23 #define MLXCPLD_I2C_DATA_REG_SZ 36 24 24 #define MLXCPLD_I2C_DATA_SZ_BIT BIT(5) 25 + #define MLXCPLD_I2C_DATA_EXT2_SZ_BIT BIT(6) 25 26 #define MLXCPLD_I2C_DATA_SZ_MASK GENMASK(6, 5) 26 27 #define MLXCPLD_I2C_SMBUS_BLK_BIT BIT(7) 27 28 #define MLXCPLD_I2C_MAX_ADDR_LEN 4 ··· 467 466 .max_comb_1st_msg_len = 4, 468 467 }; 469 468 469 + static const struct i2c_adapter_quirks mlxcpld_i2c_quirks_ext2 = { 470 + .flags = I2C_AQ_COMB_WRITE_THEN_READ, 471 + .max_read_len = (MLXCPLD_I2C_DATA_REG_SZ - 4) * 4, 472 + .max_write_len = (MLXCPLD_I2C_DATA_REG_SZ - 4) * 4 + MLXCPLD_I2C_MAX_ADDR_LEN, 473 + .max_comb_1st_msg_len = 4, 474 + }; 475 + 470 476 static struct i2c_adapter mlxcpld_i2c_adapter = { 471 477 .owner = THIS_MODULE, 472 478 .name = "i2c-mlxcpld", ··· 555 547 /* Check support for extended transaction length */ 556 548 if ((val & MLXCPLD_I2C_DATA_SZ_MASK) == MLXCPLD_I2C_DATA_SZ_BIT) 557 549 mlxcpld_i2c_adapter.quirks = &mlxcpld_i2c_quirks_ext; 550 + else if ((val & MLXCPLD_I2C_DATA_SZ_MASK) == MLXCPLD_I2C_DATA_EXT2_SZ_BIT) 551 + mlxcpld_i2c_adapter.quirks = &mlxcpld_i2c_quirks_ext2; 558 552 /* Check support for smbus block transaction */ 559 553 if (val & MLXCPLD_I2C_SMBUS_BLK_BIT) 560 554 priv->smbus_block = true;
+2 -1
drivers/i2c/busses/i2c-mpc.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/module.h> 13 13 #include <linux/sched/signal.h> 14 + #include <linux/of.h> 14 15 #include <linux/of_address.h> 15 16 #include <linux/of_irq.h> 16 - #include <linux/of_platform.h> 17 + #include <linux/platform_device.h> 17 18 #include <linux/property.h> 18 19 #include <linux/slab.h> 19 20
+4 -8
drivers/i2c/busses/i2c-mt65xx.c
··· 19 19 #include <linux/kernel.h> 20 20 #include <linux/mm.h> 21 21 #include <linux/module.h> 22 - #include <linux/of_address.h> 23 - #include <linux/of_device.h> 24 - #include <linux/of_irq.h> 22 + #include <linux/of.h> 25 23 #include <linux/platform_device.h> 26 24 #include <linux/scatterlist.h> 27 25 #include <linux/sched.h> ··· 1512 1514 clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks); 1513 1515 } 1514 1516 1515 - #ifdef CONFIG_PM_SLEEP 1516 1517 static int mtk_i2c_suspend_noirq(struct device *dev) 1517 1518 { 1518 1519 struct mtk_i2c *i2c = dev_get_drvdata(dev); ··· 1541 1544 1542 1545 return 0; 1543 1546 } 1544 - #endif 1545 1547 1546 1548 static const struct dev_pm_ops mtk_i2c_pm = { 1547 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_i2c_suspend_noirq, 1548 - mtk_i2c_resume_noirq) 1549 + NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_i2c_suspend_noirq, 1550 + mtk_i2c_resume_noirq) 1549 1551 }; 1550 1552 1551 1553 static struct platform_driver mtk_i2c_driver = { ··· 1552 1556 .remove_new = mtk_i2c_remove, 1553 1557 .driver = { 1554 1558 .name = I2C_DRV_NAME, 1555 - .pm = &mtk_i2c_pm, 1559 + .pm = pm_sleep_ptr(&mtk_i2c_pm), 1556 1560 .of_match_table = mtk_i2c_of_match, 1557 1561 }, 1558 1562 };
+2 -1
drivers/i2c/busses/i2c-mt7621.c
··· 16 16 #include <linux/io.h> 17 17 #include <linux/iopoll.h> 18 18 #include <linux/module.h> 19 - #include <linux/of_platform.h> 19 + #include <linux/of.h> 20 + #include <linux/platform_device.h> 20 21 #include <linux/reset.h> 21 22 22 23 #define REG_SM0CFG2_REG 0x28
-1
drivers/i2c/busses/i2c-mxs.c
··· 22 22 #include <linux/io.h> 23 23 #include <linux/stmp_device.h> 24 24 #include <linux/of.h> 25 - #include <linux/of_device.h> 26 25 #include <linux/dma-mapping.h> 27 26 #include <linux/dmaengine.h> 28 27 #include <linux/dma/mxs-dma.h>
+2 -2
drivers/i2c/busses/i2c-nforce2.c
··· 327 327 /* Older incarnations of the device used non-standard BARs */ 328 328 u16 iobase; 329 329 330 - if (pci_read_config_word(dev, alt_reg, &iobase) 331 - != PCIBIOS_SUCCESSFUL) { 330 + error = pci_read_config_word(dev, alt_reg, &iobase); 331 + if (error != PCIBIOS_SUCCESSFUL) { 332 332 dev_err(&dev->dev, "Error reading PCI config for %s\n", 333 333 name); 334 334 return -EIO;
+3 -9
drivers/i2c/busses/i2c-nomadik.c
··· 873 873 return IRQ_HANDLED; 874 874 } 875 875 876 - #ifdef CONFIG_PM_SLEEP 877 876 static int nmk_i2c_suspend_late(struct device *dev) 878 877 { 879 878 int ret; ··· 889 890 { 890 891 return pm_runtime_force_resume(dev); 891 892 } 892 - #endif 893 893 894 - #ifdef CONFIG_PM 895 894 static int nmk_i2c_runtime_suspend(struct device *dev) 896 895 { 897 896 struct amba_device *adev = to_amba_device(dev); ··· 922 925 923 926 return ret; 924 927 } 925 - #endif 926 928 927 929 static const struct dev_pm_ops nmk_i2c_pm = { 928 - SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) 929 - SET_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, 930 - nmk_i2c_runtime_resume, 931 - NULL) 930 + LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) 931 + RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, nmk_i2c_runtime_resume, NULL) 932 932 }; 933 933 934 934 static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) ··· 1072 1078 .drv = { 1073 1079 .owner = THIS_MODULE, 1074 1080 .name = DRIVER_NAME, 1075 - .pm = &nmk_i2c_pm, 1081 + .pm = pm_ptr(&nmk_i2c_pm), 1076 1082 }, 1077 1083 .id_table = nmk_i2c_ids, 1078 1084 .probe = nmk_i2c_probe,
-1
drivers/i2c/busses/i2c-npcm7xx.c
··· 17 17 #include <linux/mfd/syscon.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_device.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/regmap.h> 23 22
+3 -7
drivers/i2c/busses/i2c-ocores.c
··· 743 743 i2c_del_adapter(&i2c->adap); 744 744 } 745 745 746 - #ifdef CONFIG_PM_SLEEP 747 746 static int ocores_i2c_suspend(struct device *dev) 748 747 { 749 748 struct ocores_i2c *i2c = dev_get_drvdata(dev); ··· 771 772 return ocores_init(dev, i2c); 772 773 } 773 774 774 - static SIMPLE_DEV_PM_OPS(ocores_i2c_pm, ocores_i2c_suspend, ocores_i2c_resume); 775 - #define OCORES_I2C_PM (&ocores_i2c_pm) 776 - #else 777 - #define OCORES_I2C_PM NULL 778 - #endif 775 + static DEFINE_SIMPLE_DEV_PM_OPS(ocores_i2c_pm, 776 + ocores_i2c_suspend, ocores_i2c_resume); 779 777 780 778 static struct platform_driver ocores_i2c_driver = { 781 779 .probe = ocores_i2c_probe, ··· 780 784 .driver = { 781 785 .name = "ocores-i2c", 782 786 .of_match_table = ocores_i2c_match, 783 - .pm = OCORES_I2C_PM, 787 + .pm = pm_sleep_ptr(&ocores_i2c_pm), 784 788 }, 785 789 }; 786 790
+2 -1
drivers/i2c/busses/i2c-owl.c
··· 16 16 #include <linux/io.h> 17 17 #include <linux/iopoll.h> 18 18 #include <linux/module.h> 19 - #include <linux/of_device.h> 19 + #include <linux/of.h> 20 + #include <linux/platform_device.h> 20 21 21 22 /* I2C registers */ 22 23 #define OWL_I2C_REG_CTL 0x0000
-1
drivers/i2c/busses/i2c-pca-platform.c
··· 22 22 #include <linux/gpio/consumer.h> 23 23 #include <linux/io.h> 24 24 #include <linux/of.h> 25 - #include <linux/of_device.h> 26 25 27 26 #include <asm/irq.h> 28 27
+5 -10
drivers/i2c/busses/i2c-pnx.c
··· 613 613 .functionality = i2c_pnx_func, 614 614 }; 615 615 616 - #ifdef CONFIG_PM_SLEEP 617 616 static int i2c_pnx_controller_suspend(struct device *dev) 618 617 { 619 618 struct i2c_pnx_algo_data *alg_data = dev_get_drvdata(dev); ··· 629 630 return clk_prepare_enable(alg_data->clk); 630 631 } 631 632 632 - static SIMPLE_DEV_PM_OPS(i2c_pnx_pm, 633 - i2c_pnx_controller_suspend, i2c_pnx_controller_resume); 634 - #define PNX_I2C_PM (&i2c_pnx_pm) 635 - #else 636 - #define PNX_I2C_PM NULL 637 - #endif 633 + static DEFINE_SIMPLE_DEV_PM_OPS(i2c_pnx_pm, 634 + i2c_pnx_controller_suspend, 635 + i2c_pnx_controller_resume); 638 636 639 637 static int i2c_pnx_probe(struct platform_device *pdev) 640 638 { ··· 679 683 "%s", pdev->name); 680 684 681 685 /* Register I/O resource */ 682 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 683 - alg_data->ioaddr = devm_ioremap_resource(&pdev->dev, res); 686 + alg_data->ioaddr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 684 687 if (IS_ERR(alg_data->ioaddr)) 685 688 return PTR_ERR(alg_data->ioaddr); 686 689 ··· 758 763 .driver = { 759 764 .name = "pnx-i2c", 760 765 .of_match_table = of_match_ptr(i2c_pnx_of_match), 761 - .pm = PNX_I2C_PM, 766 + .pm = pm_sleep_ptr(&i2c_pnx_pm), 762 767 }, 763 768 .probe = i2c_pnx_probe, 764 769 .remove_new = i2c_pnx_remove,
-1
drivers/i2c/busses/i2c-pxa-pci.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/platform_data/i2c-pxa.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/of_address.h> 17 16 18 17 #define CE4100_PCI_I2C_DEVS 3
+6 -14
drivers/i2c/busses/i2c-pxa.c
··· 1362 1362 struct i2c_pxa_platform_data *plat = dev_get_platdata(&dev->dev); 1363 1363 enum pxa_i2c_types i2c_type; 1364 1364 struct pxa_i2c *i2c; 1365 - struct resource *res = NULL; 1365 + struct resource *res; 1366 1366 int ret, irq; 1367 1367 1368 1368 i2c = devm_kzalloc(&dev->dev, sizeof(struct pxa_i2c), GFP_KERNEL); ··· 1379 1379 i2c->adap.dev.of_node = dev->dev.of_node; 1380 1380 #endif 1381 1381 1382 - res = platform_get_resource(dev, IORESOURCE_MEM, 0); 1383 - i2c->reg_base = devm_ioremap_resource(&dev->dev, res); 1382 + i2c->reg_base = devm_platform_get_and_ioremap_resource(dev, 0, &res); 1384 1383 if (IS_ERR(i2c->reg_base)) 1385 1384 return PTR_ERR(i2c->reg_base); 1386 1385 ··· 1403 1404 strscpy(i2c->adap.name, "pxa_i2c-i2c", sizeof(i2c->adap.name)); 1404 1405 1405 1406 i2c->clk = devm_clk_get(&dev->dev, NULL); 1406 - if (IS_ERR(i2c->clk)) { 1407 - dev_err(&dev->dev, "failed to get the clk: %ld\n", PTR_ERR(i2c->clk)); 1408 - return PTR_ERR(i2c->clk); 1409 - } 1407 + if (IS_ERR(i2c->clk)) 1408 + return dev_err_probe(&dev->dev, PTR_ERR(i2c->clk), 1409 + "failed to get the clk\n"); 1410 1410 1411 1411 i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[i2c_type].ibmr; 1412 1412 i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[i2c_type].idbr; ··· 1489 1491 clk_disable_unprepare(i2c->clk); 1490 1492 } 1491 1493 1492 - #ifdef CONFIG_PM 1493 1494 static int i2c_pxa_suspend_noirq(struct device *dev) 1494 1495 { 1495 1496 struct pxa_i2c *i2c = dev_get_drvdata(dev); ··· 1513 1516 .resume_noirq = i2c_pxa_resume_noirq, 1514 1517 }; 1515 1518 1516 - #define I2C_PXA_DEV_PM_OPS (&i2c_pxa_dev_pm_ops) 1517 - #else 1518 - #define I2C_PXA_DEV_PM_OPS NULL 1519 - #endif 1520 - 1521 1519 static struct platform_driver i2c_pxa_driver = { 1522 1520 .probe = i2c_pxa_probe, 1523 1521 .remove_new = i2c_pxa_remove, 1524 1522 .driver = { 1525 1523 .name = "pxa2xx-i2c", 1526 - .pm = I2C_PXA_DEV_PM_OPS, 1524 + .pm = pm_sleep_ptr(&i2c_pxa_dev_pm_ops), 1527 1525 .of_match_table = i2c_pxa_dt_ids, 1528 1526 }, 1529 1527 .id_table = i2c_pxa_id_table,
+4 -4
drivers/i2c/busses/i2c-qcom-cci.c
··· 588 588 /* Clocks */ 589 589 590 590 ret = devm_clk_bulk_get_all(dev, &cci->clocks); 591 - if (ret < 1) { 592 - dev_err(dev, "failed to get clocks %d\n", ret); 593 - return ret; 594 - } 591 + if (ret < 0) 592 + return dev_err_probe(dev, ret, "failed to get clocks\n"); 593 + else if (!ret) 594 + return dev_err_probe(dev, -EINVAL, "not enough clocks in DT\n"); 595 595 cci->nclocks = ret; 596 596 597 597 /* Retrieve CCI clock rate */
+1 -3
drivers/i2c/busses/i2c-qcom-geni.c
··· 767 767 static int geni_i2c_probe(struct platform_device *pdev) 768 768 { 769 769 struct geni_i2c_dev *gi2c; 770 - struct resource *res; 771 770 u32 proto, tx_depth, fifo_disable; 772 771 int ret; 773 772 struct device *dev = &pdev->dev; ··· 778 779 779 780 gi2c->se.dev = dev; 780 781 gi2c->se.wrapper = dev_get_drvdata(dev->parent); 781 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 782 - gi2c->se.base = devm_ioremap_resource(dev, res); 782 + gi2c->se.base = devm_platform_ioremap_resource(pdev, 0); 783 783 if (IS_ERR(gi2c->se.base)) 784 784 return PTR_ERR(gi2c->se.base); 785 785
+4 -12
drivers/i2c/busses/i2c-qup.c
··· 1927 1927 pm_runtime_set_suspended(qup->dev); 1928 1928 } 1929 1929 1930 - #ifdef CONFIG_PM 1931 1930 static int qup_i2c_pm_suspend_runtime(struct device *device) 1932 1931 { 1933 1932 struct qup_i2c_dev *qup = dev_get_drvdata(device); ··· 1944 1945 qup_i2c_enable_clocks(qup); 1945 1946 return 0; 1946 1947 } 1947 - #endif 1948 1948 1949 - #ifdef CONFIG_PM_SLEEP 1950 1949 static int qup_i2c_suspend(struct device *device) 1951 1950 { 1952 1951 if (!pm_runtime_suspended(device)) ··· 1959 1962 pm_request_autosuspend(device); 1960 1963 return 0; 1961 1964 } 1962 - #endif 1963 1965 1964 1966 static const struct dev_pm_ops qup_i2c_qup_pm_ops = { 1965 - SET_SYSTEM_SLEEP_PM_OPS( 1966 - qup_i2c_suspend, 1967 - qup_i2c_resume) 1968 - SET_RUNTIME_PM_OPS( 1969 - qup_i2c_pm_suspend_runtime, 1970 - qup_i2c_pm_resume_runtime, 1971 - NULL) 1967 + SYSTEM_SLEEP_PM_OPS(qup_i2c_suspend, qup_i2c_resume) 1968 + RUNTIME_PM_OPS(qup_i2c_pm_suspend_runtime, 1969 + qup_i2c_pm_resume_runtime, NULL) 1972 1970 }; 1973 1971 1974 1972 static const struct of_device_id qup_i2c_dt_match[] = { ··· 1979 1987 .remove_new = qup_i2c_remove, 1980 1988 .driver = { 1981 1989 .name = "i2c_qup", 1982 - .pm = &qup_i2c_qup_pm_ops, 1990 + .pm = pm_ptr(&qup_i2c_qup_pm_ops), 1983 1991 .of_match_table = qup_i2c_dt_match, 1984 1992 .acpi_match_table = ACPI_PTR(qup_i2c_acpi_match), 1985 1993 },
+3 -9
drivers/i2c/busses/i2c-rcar.c
··· 24 24 #include <linux/i2c-smbus.h> 25 25 #include <linux/kernel.h> 26 26 #include <linux/module.h> 27 - #include <linux/of_device.h> 27 + #include <linux/of.h> 28 28 #include <linux/platform_device.h> 29 29 #include <linux/pm_runtime.h> 30 30 #include <linux/reset.h> ··· 1169 1169 pm_runtime_disable(dev); 1170 1170 } 1171 1171 1172 - #ifdef CONFIG_PM_SLEEP 1173 1172 static int rcar_i2c_suspend(struct device *dev) 1174 1173 { 1175 1174 struct rcar_i2c_priv *priv = dev_get_drvdata(dev); ··· 1186 1187 } 1187 1188 1188 1189 static const struct dev_pm_ops rcar_i2c_pm_ops = { 1189 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(rcar_i2c_suspend, rcar_i2c_resume) 1190 + NOIRQ_SYSTEM_SLEEP_PM_OPS(rcar_i2c_suspend, rcar_i2c_resume) 1190 1191 }; 1191 - 1192 - #define DEV_PM_OPS (&rcar_i2c_pm_ops) 1193 - #else 1194 - #define DEV_PM_OPS NULL 1195 - #endif /* CONFIG_PM_SLEEP */ 1196 1192 1197 1193 static struct platform_driver rcar_i2c_driver = { 1198 1194 .driver = { 1199 1195 .name = "i2c-rcar", 1200 1196 .of_match_table = rcar_i2c_dt_ids, 1201 - .pm = DEV_PM_OPS, 1197 + .pm = pm_sleep_ptr(&rcar_i2c_pm_ops), 1202 1198 }, 1203 1199 .probe = rcar_i2c_probe, 1204 1200 .remove_new = rcar_i2c_remove,
-1
drivers/i2c/busses/i2c-riic.c
··· 42 42 #include <linux/io.h> 43 43 #include <linux/module.h> 44 44 #include <linux/of.h> 45 - #include <linux/of_device.h> 46 45 #include <linux/platform_device.h> 47 46 #include <linux/pm_runtime.h> 48 47 #include <linux/reset.h>
+4 -16
drivers/i2c/busses/i2c-s3c2410.c
··· 24 24 #include <linux/slab.h> 25 25 #include <linux/io.h> 26 26 #include <linux/of.h> 27 - #include <linux/of_device.h> 28 27 #include <linux/gpio/consumer.h> 29 28 #include <linux/pinctrl/consumer.h> 30 29 #include <linux/mfd/syscon.h> ··· 1033 1034 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); 1034 1035 1035 1036 /* map the registers */ 1036 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1037 - i2c->regs = devm_ioremap_resource(&pdev->dev, res); 1038 - 1037 + i2c->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1039 1038 if (IS_ERR(i2c->regs)) 1040 1039 return PTR_ERR(i2c->regs); 1041 1040 ··· 1073 1076 if (!(i2c->quirks & QUIRK_POLL)) { 1074 1077 i2c->irq = ret = platform_get_irq(pdev, 0); 1075 1078 if (ret < 0) { 1076 - dev_err(&pdev->dev, "cannot find IRQ\n"); 1077 1079 clk_unprepare(i2c->clk); 1078 1080 return ret; 1079 1081 } ··· 1121 1125 i2c_del_adapter(&i2c->adap); 1122 1126 } 1123 1127 1124 - #ifdef CONFIG_PM_SLEEP 1125 1128 static int s3c24xx_i2c_suspend_noirq(struct device *dev) 1126 1129 { 1127 1130 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); ··· 1150 1155 1151 1156 return 0; 1152 1157 } 1153 - #endif 1154 1158 1155 - #ifdef CONFIG_PM 1156 1159 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = { 1157 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(s3c24xx_i2c_suspend_noirq, 1158 - s3c24xx_i2c_resume_noirq) 1160 + NOIRQ_SYSTEM_SLEEP_PM_OPS(s3c24xx_i2c_suspend_noirq, 1161 + s3c24xx_i2c_resume_noirq) 1159 1162 }; 1160 - 1161 - #define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops) 1162 - #else 1163 - #define S3C24XX_DEV_PM_OPS NULL 1164 - #endif 1165 1163 1166 1164 static struct platform_driver s3c24xx_i2c_driver = { 1167 1165 .probe = s3c24xx_i2c_probe, ··· 1162 1174 .id_table = s3c24xx_driver_ids, 1163 1175 .driver = { 1164 1176 .name = "s3c-i2c", 1165 - .pm = S3C24XX_DEV_PM_OPS, 1177 + .pm = pm_sleep_ptr(&s3c24xx_i2c_dev_pm_ops), 1166 1178 .of_match_table = of_match_ptr(s3c24xx_i2c_match), 1167 1179 }, 1168 1180 };
+6 -16
drivers/i2c/busses/i2c-sh_mobile.c
··· 20 20 #include <linux/io.h> 21 21 #include <linux/kernel.h> 22 22 #include <linux/module.h> 23 - #include <linux/of_device.h> 23 + #include <linux/of.h> 24 24 #include <linux/platform_device.h> 25 25 #include <linux/pm_runtime.h> 26 26 #include <linux/slab.h> ··· 871 871 { 872 872 struct sh_mobile_i2c_data *pd; 873 873 struct i2c_adapter *adap; 874 - struct resource *res; 875 874 const struct sh_mobile_dt_config *config; 876 875 int ret; 877 876 u32 bus_speed; ··· 892 893 pd->dev = &dev->dev; 893 894 platform_set_drvdata(dev, pd); 894 895 895 - res = platform_get_resource(dev, IORESOURCE_MEM, 0); 896 - 897 - pd->res = res; 898 - pd->reg = devm_ioremap_resource(&dev->dev, res); 896 + pd->reg = devm_platform_get_and_ioremap_resource(dev, 0, &pd->res); 899 897 if (IS_ERR(pd->reg)) 900 898 return PTR_ERR(pd->reg); 901 899 ··· 901 905 pd->clks_per_count = 1; 902 906 903 907 /* Newer variants come with two new bits in ICIC */ 904 - if (resource_size(res) > 0x17) 908 + if (resource_size(pd->res) > 0x17) 905 909 pd->flags |= IIC_FLAG_HAS_ICIC67; 906 910 907 911 pm_runtime_enable(&dev->dev); ··· 961 965 pm_runtime_disable(&dev->dev); 962 966 } 963 967 964 - #ifdef CONFIG_PM_SLEEP 965 968 static int sh_mobile_i2c_suspend(struct device *dev) 966 969 { 967 970 struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev); ··· 978 983 } 979 984 980 985 static const struct dev_pm_ops sh_mobile_i2c_pm_ops = { 981 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend, 982 - sh_mobile_i2c_resume) 986 + NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend, 987 + sh_mobile_i2c_resume) 983 988 }; 984 - 985 - #define DEV_PM_OPS (&sh_mobile_i2c_pm_ops) 986 - #else 987 - #define DEV_PM_OPS NULL 988 - #endif /* CONFIG_PM_SLEEP */ 989 989 990 990 static struct platform_driver sh_mobile_i2c_driver = { 991 991 .driver = { 992 992 .name = "i2c-sh_mobile", 993 993 .of_match_table = sh_mobile_i2c_dt_ids, 994 - .pm = DEV_PM_OPS, 994 + .pm = pm_sleep_ptr(&sh_mobile_i2c_pm_ops), 995 995 }, 996 996 .probe = sh_mobile_i2c_probe, 997 997 .remove_new = sh_mobile_i2c_remove,
+10 -10
drivers/i2c/busses/i2c-sis5595.c
··· 175 175 176 176 if (force_addr) { 177 177 dev_info(&SIS5595_dev->dev, "forcing ISA address 0x%04X\n", sis5595_base); 178 - if (pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base) 179 - != PCIBIOS_SUCCESSFUL) 178 + retval = pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base); 179 + if (retval != PCIBIOS_SUCCESSFUL) 180 180 goto error; 181 - if (pci_read_config_word(SIS5595_dev, ACPI_BASE, &a) 182 - != PCIBIOS_SUCCESSFUL) 181 + retval = pci_read_config_word(SIS5595_dev, ACPI_BASE, &a); 182 + if (retval != PCIBIOS_SUCCESSFUL) 183 183 goto error; 184 184 if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) { 185 185 /* doesn't work for some chips! */ ··· 188 188 } 189 189 } 190 190 191 - if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val) 192 - != PCIBIOS_SUCCESSFUL) 191 + retval = pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val); 192 + if (retval != PCIBIOS_SUCCESSFUL) 193 193 goto error; 194 194 if ((val & 0x80) == 0) { 195 195 dev_info(&SIS5595_dev->dev, "enabling ACPI\n"); 196 - if (pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80) 197 - != PCIBIOS_SUCCESSFUL) 196 + retval = pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80); 197 + if (retval != PCIBIOS_SUCCESSFUL) 198 198 goto error; 199 - if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val) 200 - != PCIBIOS_SUCCESSFUL) 199 + retval = pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val); 200 + if (retval != PCIBIOS_SUCCESSFUL) 201 201 goto error; 202 202 if ((val & 0x80) == 0) { 203 203 /* doesn't work for some chips? */
-1
drivers/i2c/busses/i2c-sprd.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_device.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/pm_runtime.h> 20 19
+1 -2
drivers/i2c/busses/i2c-st.c
··· 812 812 if (!i2c_dev) 813 813 return -ENOMEM; 814 814 815 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 816 - i2c_dev->base = devm_ioremap_resource(&pdev->dev, res); 815 + i2c_dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 817 816 if (IS_ERR(i2c_dev->base)) 818 817 return PTR_ERR(i2c_dev->base); 819 818
+1 -2
drivers/i2c/busses/i2c-stm32f4.c
··· 767 767 if (!i2c_dev) 768 768 return -ENOMEM; 769 769 770 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 771 - i2c_dev->base = devm_ioremap_resource(&pdev->dev, res); 770 + i2c_dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 772 771 if (IS_ERR(i2c_dev->base)) 773 772 return PTR_ERR(i2c_dev->base); 774 773
+4 -4
drivers/i2c/busses/i2c-stm32f7.c
··· 2121 2121 phy_addr = (dma_addr_t)res->start; 2122 2122 2123 2123 irq_event = platform_get_irq(pdev, 0); 2124 - if (irq_event <= 0) 2125 - return irq_event ? : -ENOENT; 2124 + if (irq_event < 0) 2125 + return irq_event; 2126 2126 2127 2127 irq_error = platform_get_irq(pdev, 1); 2128 - if (irq_error <= 0) 2129 - return irq_error ? : -ENOENT; 2128 + if (irq_error < 0) 2129 + return irq_error; 2130 2130 2131 2131 i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node, 2132 2132 "wakeup-source");
+10 -18
drivers/i2c/busses/i2c-synquacer.c
··· 557 557 dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk); 558 558 559 559 ret = clk_prepare_enable(i2c->pclk); 560 - if (ret) { 561 - dev_err(&pdev->dev, "failed to enable clock (%d)\n", 562 - ret); 563 - return ret; 564 - } 560 + if (ret) 561 + return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n"); 565 562 i2c->pclkrate = clk_get_rate(i2c->pclk); 566 563 } 567 564 568 565 if (i2c->pclkrate < SYNQUACER_I2C_MIN_CLK_RATE || 569 - i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE) { 570 - dev_err(&pdev->dev, "PCLK missing or out of range (%d)\n", 571 - i2c->pclkrate); 572 - return -EINVAL; 573 - } 566 + i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE) 567 + return dev_err_probe(&pdev->dev, -EINVAL, 568 + "PCLK missing or out of range (%d)\n", 569 + i2c->pclkrate); 574 570 575 571 i2c->base = devm_platform_ioremap_resource(pdev, 0); 576 572 if (IS_ERR(i2c->base)) ··· 578 582 579 583 ret = devm_request_irq(&pdev->dev, i2c->irq, synquacer_i2c_isr, 580 584 0, dev_name(&pdev->dev), i2c); 581 - if (ret < 0) { 582 - dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); 583 - return ret; 584 - } 585 + if (ret < 0) 586 + return dev_err_probe(&pdev->dev, ret, "cannot claim IRQ %d\n", i2c->irq); 585 587 586 588 i2c->state = STATE_IDLE; 587 589 i2c->dev = &pdev->dev; ··· 599 605 synquacer_i2c_hw_init(i2c); 600 606 601 607 ret = i2c_add_numbered_adapter(&i2c->adapter); 602 - if (ret) { 603 - dev_err(&pdev->dev, "failed to add bus to i2c core\n"); 604 - return ret; 605 - } 608 + if (ret) 609 + return dev_err_probe(&pdev->dev, ret, "failed to add bus to i2c core\n"); 606 610 607 611 platform_set_drvdata(pdev, i2c); 608 612
+1 -1
drivers/i2c/busses/i2c-tegra-bpmp.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/module.h> 15 - #include <linux/of_device.h> 15 + #include <linux/of.h> 16 16 #include <linux/platform_device.h> 17 17 #include <linux/pm_runtime.h> 18 18
+1 -1
drivers/i2c/busses/i2c-tegra.c
··· 22 22 #include <linux/kernel.h> 23 23 #include <linux/ktime.h> 24 24 #include <linux/module.h> 25 - #include <linux/of_device.h> 25 + #include <linux/of.h> 26 26 #include <linux/pinctrl/consumer.h> 27 27 #include <linux/platform_device.h> 28 28 #include <linux/pm_runtime.h>
+4
drivers/i2c/busses/i2c-tiny-usb.c
··· 222 222 int retval = -ENOMEM; 223 223 u16 version; 224 224 225 + if (interface->intf_assoc && 226 + interface->intf_assoc->bFunctionClass != USB_CLASS_VENDOR_SPEC) 227 + return -ENODEV; 228 + 225 229 dev_dbg(&interface->dev, "probing usb device\n"); 226 230 227 231 /* allocate memory for our device state and initialize it */
+2 -6
drivers/i2c/busses/i2c-virtio.c
··· 243 243 }; 244 244 MODULE_DEVICE_TABLE(virtio, id_table); 245 245 246 - #ifdef CONFIG_PM_SLEEP 247 246 static int virtio_i2c_freeze(struct virtio_device *vdev) 248 247 { 249 248 virtio_i2c_del_vqs(vdev); ··· 253 254 { 254 255 return virtio_i2c_setup_vqs(vdev->priv); 255 256 } 256 - #endif 257 257 258 258 static const unsigned int features[] = { 259 259 VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, ··· 267 269 .driver = { 268 270 .name = "i2c_virtio", 269 271 }, 270 - #ifdef CONFIG_PM_SLEEP 271 - .freeze = virtio_i2c_freeze, 272 - .restore = virtio_i2c_restore, 273 - #endif 272 + .freeze = pm_sleep_ptr(virtio_i2c_freeze), 273 + .restore = pm_sleep_ptr(virtio_i2c_restore), 274 274 }; 275 275 module_virtio_driver(virtio_i2c_driver); 276 276
+2 -4
drivers/i2c/busses/i2c-xlp9xx.c
··· 529 529 530 530 err = devm_request_irq(&pdev->dev, priv->irq, xlp9xx_i2c_isr, 0, 531 531 pdev->name, priv); 532 - if (err) { 533 - dev_err(&pdev->dev, "IRQ request failed!\n"); 534 - return err; 535 - } 532 + if (err) 533 + return dev_err_probe(&pdev->dev, err, "IRQ request failed!\n"); 536 534 537 535 init_completion(&priv->msg_complete); 538 536 priv->adapter.dev.parent = &pdev->dev;
+3 -3
drivers/i2c/muxes/Kconfig
··· 65 65 will be called i2c-mux-pca9541. 66 66 67 67 config I2C_MUX_PCA954x 68 - tristate "NXP PCA954x and PCA984x I2C Mux/switches" 68 + tristate "NXP PCA954x/PCA984x and Maxim MAX735x/MAX736x I2C Mux/switches" 69 69 depends on GPIOLIB || COMPILE_TEST 70 70 help 71 - If you say yes here you get support for the NXP PCA954x 72 - and PCA984x I2C mux/switch devices. 71 + If you say yes here you get support for NXP PCA954x/PCA984x 72 + and Maxim MAX735x/MAX736x I2C mux/switch devices. 73 73 74 74 This driver can also be built as a module. If so, the module 75 75 will be called i2c-mux-pca954x.
+1 -1
drivers/i2c/muxes/i2c-mux-gpmux.c
··· 11 11 #include <linux/i2c-mux.h> 12 12 #include <linux/module.h> 13 13 #include <linux/mux/consumer.h> 14 - #include <linux/of_device.h> 14 + #include <linux/of.h> 15 15 #include <linux/platform_device.h> 16 16 17 17 struct mux {
+1 -2
drivers/i2c/muxes/i2c-mux-ltc4306.c
··· 15 15 #include <linux/i2c.h> 16 16 #include <linux/module.h> 17 17 #include <linux/of.h> 18 - #include <linux/of_device.h> 19 18 #include <linux/property.h> 20 19 #include <linux/regmap.h> 21 20 #include <linux/slab.h> ··· 61 62 62 63 static bool ltc4306_is_volatile_reg(struct device *dev, unsigned int reg) 63 64 { 64 - return (reg == LTC_REG_CONFIG) ? true : false; 65 + return reg == LTC_REG_CONFIG; 65 66 } 66 67 67 68 static const struct regmap_config ltc4306_regmap_config = {
+91 -10
drivers/i2c/muxes/i2c-mux-pca954x.c
··· 11 11 * PCA9540, PCA9542, PCA9543, PCA9544, PCA9545, PCA9546, PCA9547, 12 12 * PCA9548, PCA9846, PCA9847, PCA9848 and PCA9849. 13 13 * 14 + * It's also compatible to Maxims MAX735x I2C switch chips, which are controlled 15 + * as the NXP PCA9548 and the MAX736x chips that act like the PCA9544. 16 + * 17 + * This includes the: 18 + * MAX7356, MAX7357, MAX7358, MAX7367, MAX7368 and MAX7369 19 + * 14 20 * These chips are all controlled via the I2C bus itself, and all have a 15 21 * single 8-bit register. The upstream "parent" bus fans out to two, 16 22 * four, or eight downstream busses or channels; which of these ··· 48 42 #include <linux/module.h> 49 43 #include <linux/pm.h> 50 44 #include <linux/property.h> 45 + #include <linux/regulator/consumer.h> 51 46 #include <linux/slab.h> 52 47 #include <linux/spinlock.h> 53 48 #include <dt-bindings/mux/mux.h> ··· 58 51 #define PCA954X_IRQ_OFFSET 4 59 52 60 53 enum pca_type { 54 + max_7356, 55 + max_7357, 56 + max_7358, 57 + max_7367, 58 + max_7368, 59 + max_7369, 61 60 pca_9540, 62 61 pca_9542, 63 62 pca_9543, ··· 101 88 struct irq_domain *irq; 102 89 unsigned int irq_mask; 103 90 raw_spinlock_t lock; 91 + struct regulator *supply; 104 92 }; 105 93 106 - /* Provide specs for the PCA954x types we know about */ 94 + /* Provide specs for the MAX735x, PCA954x and PCA984x types we know about */ 107 95 static const struct chip_desc chips[] = { 96 + [max_7356] = { 97 + .nchans = 8, 98 + .muxtype = pca954x_isswi, 99 + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, 100 + }, 101 + [max_7357] = { 102 + .nchans = 8, 103 + .muxtype = pca954x_isswi, 104 + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, 105 + /* 106 + * No interrupt controller support. The interrupt 107 + * provides information about stuck channels. 108 + */ 109 + }, 110 + [max_7358] = { 111 + .nchans = 8, 112 + .muxtype = pca954x_isswi, 113 + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, 114 + /* 115 + * No interrupt controller support. The interrupt 116 + * provides information about stuck channels. 117 + */ 118 + }, 119 + [max_7367] = { 120 + .nchans = 4, 121 + .muxtype = pca954x_isswi, 122 + .has_irq = 1, 123 + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, 124 + }, 125 + [max_7368] = { 126 + .nchans = 4, 127 + .muxtype = pca954x_isswi, 128 + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, 129 + }, 130 + [max_7369] = { 131 + .nchans = 4, 132 + .enable = 0x4, 133 + .muxtype = pca954x_ismux, 134 + .has_irq = 1, 135 + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, 136 + }, 108 137 [pca_9540] = { 109 138 .nchans = 2, 110 139 .enable = 0x4, ··· 232 177 }; 233 178 234 179 static const struct i2c_device_id pca954x_id[] = { 180 + { "max7356", max_7356 }, 181 + { "max7357", max_7357 }, 182 + { "max7358", max_7358 }, 183 + { "max7367", max_7367 }, 184 + { "max7368", max_7368 }, 185 + { "max7369", max_7369 }, 235 186 { "pca9540", pca_9540 }, 236 187 { "pca9542", pca_9542 }, 237 188 { "pca9543", pca_9543 }, ··· 255 194 MODULE_DEVICE_TABLE(i2c, pca954x_id); 256 195 257 196 static const struct of_device_id pca954x_of_match[] = { 197 + { .compatible = "maxim,max7356", .data = &chips[max_7356] }, 198 + { .compatible = "maxim,max7357", .data = &chips[max_7357] }, 199 + { .compatible = "maxim,max7358", .data = &chips[max_7358] }, 200 + { .compatible = "maxim,max7367", .data = &chips[max_7367] }, 201 + { .compatible = "maxim,max7368", .data = &chips[max_7368] }, 202 + { .compatible = "maxim,max7369", .data = &chips[max_7369] }, 258 203 { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, 259 204 { .compatible = "nxp,pca9542", .data = &chips[pca_9542] }, 260 205 { .compatible = "nxp,pca9543", .data = &chips[pca_9543] }, ··· 449 382 struct pca954x *data = i2c_mux_priv(muxc); 450 383 int c, irq; 451 384 385 + regulator_disable(data->supply); 386 + 452 387 if (data->irq) { 453 388 for (c = 0; c < data->chip->nchans; c++) { 454 389 irq = irq_find_mapping(data->irq, c); ··· 503 434 i2c_set_clientdata(client, muxc); 504 435 data->client = client; 505 436 437 + data->supply = devm_regulator_get(dev, "vdd"); 438 + if (IS_ERR(data->supply)) 439 + return dev_err_probe(dev, PTR_ERR(data->supply), 440 + "Failed to request regulator\n"); 441 + 442 + ret = regulator_enable(data->supply); 443 + if (ret) 444 + return dev_err_probe(dev, ret, 445 + "Failed to enable vdd supply\n"); 446 + 506 447 /* Reset the mux if a reset GPIO is specified. */ 507 448 gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 508 - if (IS_ERR(gpio)) 509 - return PTR_ERR(gpio); 449 + if (IS_ERR(gpio)) { 450 + ret = PTR_ERR(gpio); 451 + goto fail_cleanup; 452 + } 510 453 if (gpio) { 511 454 udelay(1); 512 455 gpiod_set_value_cansleep(gpio, 0); ··· 535 454 536 455 ret = i2c_get_device_id(client, &id); 537 456 if (ret && ret != -EOPNOTSUPP) 538 - return ret; 457 + goto fail_cleanup; 539 458 540 459 if (!ret && 541 460 (id.manufacturer_id != data->chip->id.manufacturer_id || ··· 543 462 dev_warn(dev, "unexpected device id %03x-%03x-%x\n", 544 463 id.manufacturer_id, id.part_id, 545 464 id.die_revision); 546 - return -ENODEV; 465 + ret = -ENODEV; 466 + goto fail_cleanup; 547 467 } 548 468 } 549 469 ··· 563 481 ret = pca954x_init(client, data); 564 482 if (ret < 0) { 565 483 dev_warn(dev, "probe failed\n"); 566 - return -ENODEV; 484 + ret = -ENODEV; 485 + goto fail_cleanup; 567 486 } 568 487 569 488 ret = pca954x_irq_setup(muxc); ··· 613 530 pca954x_cleanup(muxc); 614 531 } 615 532 616 - #ifdef CONFIG_PM_SLEEP 617 533 static int pca954x_resume(struct device *dev) 618 534 { 619 535 struct i2c_client *client = to_i2c_client(dev); ··· 626 544 627 545 return ret; 628 546 } 629 - #endif 630 547 631 - static SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume); 548 + static DEFINE_SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume); 632 549 633 550 static struct i2c_driver pca954x_driver = { 634 551 .driver = { 635 552 .name = "pca954x", 636 - .pm = &pca954x_pm, 553 + .pm = pm_sleep_ptr(&pca954x_pm), 637 554 .of_match_table = pca954x_of_match, 638 555 }, 639 556 .probe = pca954x_probe,
-2
include/linux/virtio.h
··· 191 191 void (*scan)(struct virtio_device *dev); 192 192 void (*remove)(struct virtio_device *dev); 193 193 void (*config_changed)(struct virtio_device *dev); 194 - #ifdef CONFIG_PM 195 194 int (*freeze)(struct virtio_device *dev); 196 195 int (*restore)(struct virtio_device *dev); 197 - #endif 198 196 }; 199 197 200 198 static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv)