History

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

Pull i2c updates from Wolfram Sang: "I2C has largely driver updates for 6.7, i.e. feature additions (like adding transfers while in atomic mode), using new helpers (like devm_clk_get_enabled), new IDs, documentation fixes and additions... you name it. The core got a memleak fix and better support for nested muxes" * tag 'i2c-for-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (53 commits) i2c: s3c2410: make i2c_s3c_irq_nextbyte() void i2c: qcom-geni: add ACPI device id for sc8180x Documentation: i2c: add fault code for not supporting 10 bit addresses i2c: sun6i-p2wi: Prevent potential division by zero i2c: mux: demux-pinctrl: Convert to use sysfs_emit_at() API i2c: i801: Use new helper acpi_use_parent_companion ACPI: Add helper acpi_use_parent_companion MAINTAINERS: add YAML file for i2c-demux-pinctrl i2c: core: fix lockdep warning for sparsely nested adapter chain i2c: axxia: eliminate kernel-doc warnings dt-bindings: i2c: i2c-demux-pinctrl: Convert to json-schema i2c: stm32f7: Use devm_clk_get_enabled() i2c: stm32f4: Use devm_clk_get_enabled() i2c: stm32f7: add description of atomic in struct stm32f7_i2c_dev i2c: fix memleak in i2c_new_client_device() i2c: exynos5: Calculate t_scl_l, t_scl_h according to i2c spec i2c: i801: Simplify class-based client device instantiation i2c: exynos5: add support for atomic transfers i2c: at91-core: Use devm_clk_get_enabled() eeprom: at24: add ST M24C64-D Additional Write lockable page support ...

Linus Torvalds committed 3 years ago

Commit 3d05e492 parents 2153fc3 10e806d34 files · +595 −426Browse files

Unified · Split

34 files
  1. Documentation/devicetree/bindings/eeprom/at24.yaml +4 −0
  2. Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt +0 −135
  3. Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.yaml +172 −0
  4. Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml +2 −0
  5. Documentation/i2c/busses/i2c-i801.rst +1 −0
  6. Documentation/i2c/fault-codes.rst +4 −0
  7. MAINTAINERS +1 −0
  8. drivers/i2c/busses/Kconfig +1 −0
  9. drivers/i2c/busses/i2c-at91-core.c +3 −7
  10. drivers/i2c/busses/i2c-axxia.c +5 −3
  11. drivers/i2c/busses/i2c-brcmstb.c +21 −2
  12. drivers/i2c/busses/i2c-cp2615.c +1 −1
  13. drivers/i2c/busses/i2c-exynos5.c +75 −5
  14. drivers/i2c/busses/i2c-gpio.c +1 −6
  15. drivers/i2c/busses/i2c-i801.c +42 −68
  16. drivers/i2c/busses/i2c-mt65xx.c +8 −4
  17. drivers/i2c/busses/i2c-mv64xxx.c +5 −6
  18. drivers/i2c/busses/i2c-omap.c +3 −5
  19. drivers/i2c/busses/i2c-powermac.c +1 −1
  20. drivers/i2c/busses/i2c-pxa.c +3 −4
  21. drivers/i2c/busses/i2c-qcom-geni.c +1 −0
  22. drivers/i2c/busses/i2c-rcar.c +113 −67
  23. drivers/i2c/busses/i2c-riic.c +1 −1
  24. drivers/i2c/busses/i2c-s3c2410.c +3 −4
  25. drivers/i2c/busses/i2c-stm32f4.c +10 −22
  26. drivers/i2c/busses/i2c-stm32f7.c +60 −29
  27. drivers/i2c/busses/i2c-sun6i-p2wi.c +5 −0
  28. drivers/i2c/i2c-atr.c +1 −1
  29. drivers/i2c/i2c-core-base.c +13 −6
  30. drivers/i2c/i2c-dev.c +9 −9
  31. drivers/i2c/muxes/i2c-demux-pinctrl.c +6 −6
  32. drivers/i2c/muxes/i2c-mux-gpio.c +3 −4
  33. drivers/misc/eeprom/at24.c +12 −30
  34. include/linux/acpi.h +5 −0
Documentation/devicetree/bindings/eeprom/at24.yaml+4−0
@@ -68,10 +68,14 @@ properties: · 67 unmodified lines
6868 pattern: cs16$
6969 - items:
7070 pattern: c32$
71+ - items:
72+ pattern: c32d-wl$
7173 - items:
7274 pattern: cs32$
7375 - items:
7476 pattern: c64$
77+ - items:
78+ pattern: c64d-wl$
7579 - items:
7680 pattern: cs64$
7781 - items:
Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt+0−135
@@ -1,135 +0,0 @@
1−Pinctrl-based I2C Bus DeMux
2−
3−This binding describes an I2C bus demultiplexer that uses pin multiplexing to
4−route the I2C signals, and represents the pin multiplexing configuration using
5−the pinctrl device tree bindings. This may be used to select one I2C IP core at
6−runtime which may have a better feature set for a given task than another I2C
7−IP core on the SoC. The most simple example is to fall back to GPIO bitbanging
8−if your current runtime configuration hits an errata of the internal IP core.
9−
10− +-------------------------------+
11− | SoC |
12− | | +-----+ +-----+
13− | +------------+ | | dev | | dev |
14− | |I2C IP Core1|--\ | +-----+ +-----+
15− | +------------+ \-------+ | | |
16− | |Pinctrl|--|------+--------+
17− | +------------+ +-------+ |
18− | |I2C IP Core2|--/ |
19− | +------------+ |
20− | |
21− +-------------------------------+
22−
23−Required properties:
24−- compatible: "i2c-demux-pinctrl"
25−- i2c-parent: List of phandles of I2C masters available for selection. The first
26− one will be used as default.
27−- i2c-bus-name: The name of this bus. Also needed as pinctrl-name for the I2C
28− parents.
29−
30−Furthermore, I2C mux properties and child nodes. See i2c-mux.yaml in this
31−directory.
32−
33−Example:
34−
35−Here is a snipplet for a bus to be demuxed. It contains various i2c clients for
36−HDMI, so the bus is named "i2c-hdmi":
37−
38− i2chdmi: i2c@8 {
39−
40− compatible = "i2c-demux-pinctrl";
41− i2c-parent = <&gpioi2c>, <&iic2>, <&i2c2>;
42− i2c-bus-name = "i2c-hdmi";
43− #address-cells = <1>;
44− #size-cells = <0>;
45−
46− ak4643: sound-codec@12 {
47− compatible = "asahi-kasei,ak4643";
48−
49− #sound-dai-cells = <0>;
50− reg = <0x12>;
51− };
52−
53− composite-in@20 {
54− compatible = "adi,adv7180";
55− reg = <0x20>;
56− remote = <&vin1>;
57−
58− port {
59− adv7180: endpoint {
60− bus-width = <8>;
61− remote-endpoint = <&vin1ep0>;
62− };
63− };
64− };
65−
66− hdmi@39 {
67− compatible = "adi,adv7511w";
68− reg = <0x39>;
69− interrupt-parent = <&gpio1>;
70− interrupts = <15 IRQ_TYPE_LEVEL_LOW>;
71−
72− adi,input-depth = <8>;
73− adi,input-colorspace = "rgb";
74− adi,input-clock = "1x";
75− adi,input-style = <1>;
76− adi,input-justification = "evenly";
77−
78− ports {
79− #address-cells = <1>;
80− #size-cells = <0>;
81−
82− port@0 {
83− reg = <0>;
84− adv7511_in: endpoint {
85− remote-endpoint = <&du_out_lvds0>;
86− };
87− };
88−
89− port@1 {
90− reg = <1>;
91− adv7511_out: endpoint {
92− remote-endpoint = <&hdmi_con>;
93− };
94− };
95− };
96− };
97− };
98−
99−And for clarification, here are the snipplets for the i2c-parents:
100−
101− gpioi2c: i2c@9 {
102− #address-cells = <1>;
103− #size-cells = <0>;
104− compatible = "i2c-gpio";
105− gpios = <&gpio5 6 GPIO_ACTIVE_HIGH /* sda */
106− &gpio5 5 GPIO_ACTIVE_HIGH /* scl */
107− >;
108− i2c-gpio,delay-us = <5>;
109− };
110−
111−...
112−
113−&i2c2 {
114− pinctrl-0 = <&i2c2_pins>;
115− pinctrl-names = "i2c-hdmi";
116−
117− clock-frequency = <100000>;
118−};
119−
120−...
121−
122−&iic2 {
123− pinctrl-0 = <&iic2_pins>;
124− pinctrl-names = "i2c-hdmi";
125−
126− clock-frequency = <100000>;
127−};
128−
129−Please note:
130−
131−- pinctrl properties for the parent I2C controllers need a pinctrl state
132− with the same name as i2c-bus-name, not "default"!
133−
134−- the i2c masters must have their status "disabled". This driver will
135− enable them at runtime when needed.
Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.yaml+172−0
@@ -0,0 +1,172 @@
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-demux-pinctrl.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+title: Pinctrl-based I2C Bus Demultiplexer
8+
9+maintainers:
10+ - Wolfram Sang <wsa+renesas@sang-engineering.com>
11+
12+description: |
13+ This binding describes an I2C bus demultiplexer that uses pin multiplexing to
14+ route the I2C signals, and represents the pin multiplexing configuration
15+ using the pinctrl device tree bindings. This may be used to select one I2C
16+ IP core at runtime which may have a better feature set for a given task than
17+ another I2C IP core on the SoC. The most simple example is to fall back to
18+ GPIO bitbanging if your current runtime configuration hits an errata of the
19+ internal IP core.
20+
21+ +-------------------------------+
22+ | SoC |
23+ | | +-----+ +-----+
24+ | +------------+ | | dev | | dev |
25+ | |I2C IP Core1|--\ | +-----+ +-----+
26+ | +------------+ \-------+ | | |
27+ | |Pinctrl|--|------+--------+
28+ | +------------+ +-------+ |
29+ | |I2C IP Core2|--/ |
30+ | +------------+ |
31+ | |
32+ +-------------------------------+
33+
34+allOf:
35+ - $ref: i2c-mux.yaml
36+ - $ref: /schemas/i2c/i2c-controller.yaml#
37+
38+properties:
39+ compatible:
40+ const: i2c-demux-pinctrl
41+
42+ i2c-parent:
43+ $ref: /schemas/types.yaml#/definitions/phandle-array
44+ description:
45+ List of phandles of I2C masters available for selection. The first one
46+ will be used as default.
47+
48+ i2c-bus-name:
49+ $ref: /schemas/types.yaml#/definitions/string
50+ description:
51+ The name of this bus. Also needed as pinctrl-name for the I2C parents.
52+
53+required:
54+ - compatible
55+ - i2c-parent
56+ - i2c-bus-name
57+
58+unevaluatedProperties: false
59+
60+examples:
61+ - |
62+ #include <dt-bindings/gpio/gpio.h>
63+ #include <dt-bindings/interrupt-controller/irq.h>
64+
65+ gpioi2c2: i2c-9 {
66+ #address-cells = <1>;
67+ #size-cells = <0>;
68+ compatible = "i2c-gpio";
69+ scl-gpios = <&gpio5 5 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
70+ sda-gpios = <&gpio5 6 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
71+ i2c-gpio,delay-us = <5>;
72+
73+ // The I2C controller must have its status "disabled". The I2C bus
74+ // demultiplexer will enable it at runtime when needed.
75+ status = "disabled";
76+ };
77+
78+ iic2: i2c@e6520000 {
79+ reg = <0xe6520000 0x425>;
80+ pinctrl-0 = <&iic2_pins>;
81+ // The pinctrl property for the parent I2C controller needs a pinctrl
82+ // state with the same name as i2c-bus-name in the I2C bus demultiplexer
83+ // node, not "default"!
84+ pinctrl-names = "i2c-hdmi";
85+
86+ clock-frequency = <100000>;
87+
88+ // The I2C controller must have its status "disabled". The I2C bus
89+ // demultiplexer will enable it at runtime when needed.
90+ status = "disabled";
91+ };
92+
93+ i2c2: i2c@e6530000 {
94+ reg = <0 0xe6530000 0 0x40>;
95+ pinctrl-0 = <&i2c2_pins>;
96+ // The pinctrl property for the parent I2C controller needs a pinctrl
97+ // state with the same name as i2c-bus-name in the I2C bus demultiplexer
98+ // node, not "default"!
99+ pinctrl-names = "i2c-hdmi";
100+
101+ clock-frequency = <100000>;
102+
103+ // The I2C controller must have its status "disabled". The I2C bus
104+ // demultiplexer will enable it at runtime when needed.
105+ status = "disabled";
106+ };
107+
108+ // Example for a bus to be demuxed. It contains various I2C clients for
109+ // HDMI, so the bus is named "i2c-hdmi":
110+ i2chdmi: i2c-mux3 {
111+ compatible = "i2c-demux-pinctrl";
112+ i2c-parent = <&iic2>, <&i2c2>, <&gpioi2c2>;
113+ i2c-bus-name = "i2c-hdmi";
114+ #address-cells = <1>;
115+ #size-cells = <0>;
116+
117+ ak4643: codec@12 {
118+ compatible = "asahi-kasei,ak4643";
119+ #sound-dai-cells = <0>;
120+ reg = <0x12>;
121+ };
122+
123+ composite-in@20 {
124+ compatible = "adi,adv7180";
125+ reg = <0x20>;
126+
127+ port {
128+ adv7180: endpoint {
129+ bus-width = <8>;
130+ remote-endpoint = <&vin1ep0>;
131+ };
132+ };
133+ };
134+
135+ hdmi@39 {
136+ compatible = "adi,adv7511w";
137+ reg = <0x39>;
138+ interrupt-parent = <&gpio1>;
139+ interrupts = <15 IRQ_TYPE_LEVEL_LOW>;
140+ clocks = <&cec_clock>;
141+ clock-names = "cec";
142+
143+ avdd-supply = <&fixedregulator1v8>;
144+ dvdd-supply = <&fixedregulator1v8>;
145+ pvdd-supply = <&fixedregulator1v8>;
146+ dvdd-3v-supply = <&fixedregulator3v3>;
147+ bgvdd-supply = <&fixedregulator1v8>;
148+
149+ adi,input-depth = <8>;
150+ adi,input-colorspace = "rgb";
151+ adi,input-clock = "1x";
152+
153+ ports {
154+ #address-cells = <1>;
155+ #size-cells = <0>;
156+
157+ port@0 {
158+ reg = <0>;
159+ adv7511_in: endpoint {
160+ remote-endpoint = <&lvds0_out>;
161+ };
162+ };
163+
164+ port@1 {
165+ reg = <1>;
166+ adv7511_out: endpoint {
167+ remote-endpoint = <&hdmi_con_out>;
168+ };
169+ };
170+ };
171+ };
172+ };
Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml+2−0
@@ -25,6 +25,7 @@ properties: · 24 unmodified lines
2525
2626 - items:
2727 - enum:
28+ - qcom,sc7280-cci
2829 - qcom,sdm845-cci
2930 - qcom,sm6350-cci
3031 - qcom,sm8250-cci
@@ -159,6 +160,7 @@ allOf: · 128 unmodified lines
159160 compatible:
160161 contains:
161162 enum:
163+ - qcom,sc7280-cci
162164 - qcom,sm8250-cci
163165 - qcom,sm8450-cci
164166 then:
Documentation/i2c/busses/i2c-i801.rst+1−0
@@ -47,6 +47,7 @@ Supported adapters: · 46 unmodified lines
4747 * Intel Alder Lake (PCH)
4848 * Intel Raptor Lake (PCH)
4949 * Intel Meteor Lake (SOC and PCH)
50+ * Intel Birch Stream (SOC)
5051
5152 Datasheets: Publicly available at the Intel website
5253
Documentation/i2c/fault-codes.rst+4−0
@@ -39,6 +39,10 @@ Also, codes returned by adapter probe methods follow rules which are · 38 unmodified lines
3939 specific to their host bus (such as PCI, or the platform bus).
4040
4141
42+EAFNOSUPPORT
43+ Returned by I2C adapters not supporting 10 bit addresses when
44+ they are requested to use such an address.
45+
4246 EAGAIN
4347 Returned by I2C adapters when they lose arbitration in master
4448 transmit mode: some other master was transmitting different
MAINTAINERS+1−0
@@ -8825,6 +8825,7 @@ F: include/linux/phy/ · 8824 unmodified lines
88258825 GENERIC PINCTRL I2C DEMULTIPLEXER DRIVER
88268826 M: Wolfram Sang <wsa+renesas@sang-engineering.com>
88278827 S: Supported
8828+F: Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.yaml
88288829 F: drivers/i2c/muxes/i2c-demux-pinctrl.c
88298830
88308831 GENERIC PM DOMAINS
drivers/i2c/busses/Kconfig+1−0
@@ -158,6 +158,7 @@ config I2C_I801 · 157 unmodified lines
158158 Alder Lake (PCH)
159159 Raptor Lake (PCH)
160160 Meteor Lake (SOC and PCH)
161+ Birch Stream (SOC)
161162
162163 This driver can also be built as a module. If so, the module
163164 will be called i2c-i801.
drivers/i2c/busses/i2c-at91-core.c+3−7
@@ -221,11 +221,10 @@ static int at91_twi_probe(struct platform_device *pdev) · 220 unmodified lines
221221
222222 platform_set_drvdata(pdev, dev);
223223
224− dev->clk = devm_clk_get(dev->dev, NULL);
224+ dev->clk = devm_clk_get_enabled(dev->dev, NULL);
225225 if (IS_ERR(dev->clk))
226− return dev_err_probe(dev->dev, PTR_ERR(dev->clk), "no clock defined\n");
227−
228− clk_prepare_enable(dev->clk);
226+ return dev_err_probe(dev->dev, PTR_ERR(dev->clk),
227+ "failed to enable clock\n");
229228
230229 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
231230 i2c_set_adapdata(&dev->adapter, dev);
@@ -254,8 +253,6 @@ static int at91_twi_probe(struct platform_device *pdev) · 22 unmodified lines
254253
255254 rc = i2c_add_numbered_adapter(&dev->adapter);
256255 if (rc) {
257− clk_disable_unprepare(dev->clk);
258−
259256 pm_runtime_disable(dev->dev);
260257 pm_runtime_set_suspended(dev->dev);
261258
@@ -272,7 +269,6 @@ static void at91_twi_remove(struct platform_device *pdev) · 10 unmodified lines
272269 struct at91_twi_dev *dev = platform_get_drvdata(pdev);
273270
274271 i2c_del_adapter(&dev->adapter);
275− clk_disable_unprepare(dev->clk);
276272
277273 pm_runtime_disable(dev->dev);
278274 pm_runtime_set_suspended(dev->dev);
drivers/i2c/busses/i2c-axxia.c+5−3
@@ -131,6 +131,8 @@ · 130 unmodified lines
131131 * @i2c_clk: clock reference for i2c input clock
132132 * @bus_clk_rate: current i2c bus clock rate
133133 * @last: a flag indicating is this is last message in transfer
134+ * @slave: associated &i2c_client
135+ * @irq: platform device IRQ number
134136 */
135137 struct axxia_i2c_dev {
136138 void __iomem *base;
@@ -165,7 +167,7 @@ static void i2c_int_enable(struct axxia_i2c_dev *idev, u32 mask) · 28 unmodified lines
165167 writel(int_en | mask, idev->base + MST_INT_ENABLE);
166168 }
167169
168−/**
170+/*
169171 * ns_to_clk - Convert time (ns) to clock cycles for the given clock frequency.
170172 */
171173 static u32 ns_to_clk(u64 ns, u32 clk_mhz)
@@ -263,7 +265,7 @@ static int i2c_m_recv_len(const struct i2c_msg *msg) · 91 unmodified lines
263265 return (msg->flags & I2C_M_RECV_LEN) != 0;
264266 }
265267
266−/**
268+/*
267269 * axxia_i2c_empty_rx_fifo - Fetch data from RX FIFO and update SMBus block
268270 * transfer length if this is the first byte of such a transfer.
269271 */
@@ -295,7 +297,7 @@ static int axxia_i2c_empty_rx_fifo(struct axxia_i2c_dev *idev) · 25 unmodified lines
295297 return 0;
296298 }
297299
298−/**
300+/*
299301 * axxia_i2c_fill_tx_fifo - Fill TX FIFO from current message buffer.
300302 * @return: Number of bytes left to transfer.
301303 */
drivers/i2c/busses/i2c-brcmstb.c+21−2
@@ -160,6 +160,7 @@ struct brcmstb_i2c_dev { · 159 unmodified lines
160160 struct completion done;
161161 u32 clk_freq_hz;
162162 int data_regsz;
163+ bool atomic;
163164 };
164165
165166 /* register accessors for both be and le cpu arch */
@@ -240,7 +241,7 @@ static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev) · 74 unmodified lines
240241 int ret = 0;
241242 unsigned long timeout = msecs_to_jiffies(I2C_TIMEOUT);
242243
243− if (dev->irq >= 0) {
244+ if (dev->irq >= 0 && !dev->atomic) {
244245 if (!wait_for_completion_timeout(&dev->done, timeout))
245246 ret = -ETIMEDOUT;
246247 } else {
@@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev, · 40 unmodified lines
287288 return rc;
288289
289290 /* only if we are in interrupt mode */
290− if (dev->irq >= 0)
291+ if (dev->irq >= 0 && !dev->atomic)
291292 reinit_completion(&dev->done);
292293
293294 /* enable BSC CTL interrupt line */
@@ -520,6 +521,23 @@ out: · 226 unmodified lines
520521
521522 }
522523
524+static int brcmstb_i2c_xfer_atomic(struct i2c_adapter *adapter,
525+ struct i2c_msg msgs[], int num)
526+{
527+ struct brcmstb_i2c_dev *dev = i2c_get_adapdata(adapter);
528+ int ret;
529+
530+ if (dev->irq >= 0)
531+ disable_irq(dev->irq);
532+ dev->atomic = true;
533+ ret = brcmstb_i2c_xfer(adapter, msgs, num);
534+ dev->atomic = false;
535+ if (dev->irq >= 0)
536+ enable_irq(dev->irq);
537+
538+ return ret;
539+}
540+
523541 static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap)
524542 {
525543 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR
@@ -528,6 +546,7 @@ static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap) · 2 unmodified lines
528546
529547 static const struct i2c_algorithm brcmstb_i2c_algo = {
530548 .master_xfer = brcmstb_i2c_xfer,
549+ .master_xfer_atomic = brcmstb_i2c_xfer_atomic,
531550 .functionality = brcmstb_i2c_functionality,
532551 };
533552
drivers/i2c/busses/i2c-cp2615.c+1−1
@@ -298,7 +298,7 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id) · 297 unmodified lines
298298 if (!adap)
299299 return -ENOMEM;
300300
301− strncpy(adap->name, usbdev->serial, sizeof(adap->name) - 1);
301+ strscpy(adap->name, usbdev->serial, sizeof(adap->name));
302302 adap->owner = THIS_MODULE;
303303 adap->dev.parent = &usbif->dev;
304304 adap->dev.of_node = usbif->dev.of_node;
drivers/i2c/busses/i2c-exynos5.c+75−5
@@ -194,6 +194,11 @@ struct exynos5_i2c { · 193 unmodified lines
194194 */
195195 int trans_done;
196196
197+ /*
198+ * Called from atomic context, don't use interrupts.
199+ */
200+ unsigned int atomic;
201+
197202 /* Controller operating frequency */
198203 unsigned int op_clock;
199204
@@ -265,7 +270,7 @@ static void exynos5_i2c_clr_pend_irq(struct exynos5_i2c *i2c) · 65 unmodified lines
265270 * exynos5_i2c_set_timing: updates the registers with appropriate
266271 * timing values calculated
267272 *
268− * Timing values for operation are calculated against either 100kHz
273+ * Timing values for operation are calculated against 100kHz, 400kHz
269274 * or 1MHz controller operating frequency.
270275 *
271276 * Returns 0 on success, -EINVAL if the cycle length cannot
@@ -328,6 +333,23 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, bool hs_timings) · 56 unmodified lines
328333 *
329334 * Constraints: 4 <= temp, 0 <= CLK_DIV < 256, 2 <= clk_cycle <= 510
330335 *
336+ * To split SCL clock into low, high periods appropriately, one
337+ * proportion factor for each I2C mode is used, which is calculated
338+ * using this formula.
339+ * ```
340+ * ((t_low_min + (scl_clock - t_low_min - t_high_min) / 2) / scl_clock)
341+ * ```
342+ * where:
343+ * t_low_min is the minimal value of low period of the SCL clock in us;
344+ * t_high_min is the minimal value of high period of the SCL clock in us;
345+ * scl_clock is converted from SCL clock frequency into us.
346+ *
347+ * Below are the proportion factors for these I2C modes:
348+ * t_low_min, t_high_min, scl_clock, proportion
349+ * Standard Mode: 4.7us, 4.0us, 10us, 0.535
350+ * Fast Mode: 1.3us, 0.6us, 2.5us, 0.64
351+ * Fast-Plus Mode: 0.5us, 0.26us, 1us, 0.62
352+ *
331353 */
332354 t_ftl_cycle = (readl(i2c->regs + HSI2C_CONF) >> 16) & 0x7;
333355 temp = clkin / op_clk - 8 - t_ftl_cycle;
@@ -341,8 +363,19 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, bool hs_timings) · 7 unmodified lines
341363 return -EINVAL;
342364 }
343365
344− t_scl_l = clk_cycle / 2;
345− t_scl_h = clk_cycle / 2;
366+ /*
367+ * Scale clk_cycle to get t_scl_l using the proption factors for individual I2C modes.
368+ */
369+ if (op_clk <= I2C_MAX_STANDARD_MODE_FREQ)
370+ t_scl_l = clk_cycle * 535 / 1000;
371+ else if (op_clk <= I2C_MAX_FAST_MODE_FREQ)
372+ t_scl_l = clk_cycle * 64 / 100;
373+ else
374+ t_scl_l = clk_cycle * 62 / 100;
375+
376+ if (t_scl_l > 0xFF)
377+ t_scl_l = 0xFF;
378+ t_scl_h = clk_cycle - t_scl_l;
346379 t_start_su = t_scl_l;
347380 t_start_hd = t_scl_l;
348381 t_stop_su = t_scl_l;
@@ -711,6 +744,22 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) · 362 unmodified lines
711744 spin_unlock_irqrestore(&i2c->lock, flags);
712745 }
713746
747+static bool exynos5_i2c_poll_irqs_timeout(struct exynos5_i2c *i2c,
748+ unsigned long timeout)
749+{
750+ unsigned long time_left = jiffies + timeout;
751+
752+ while (time_before(jiffies, time_left) &&
753+ !((i2c->trans_done && (i2c->msg->len == i2c->msg_ptr)) ||
754+ (i2c->state < 0))) {
755+ while (readl(i2c->regs + HSI2C_INT_ENABLE) &
756+ readl(i2c->regs + HSI2C_INT_STATUS))
757+ exynos5_i2c_irq(i2c->irq, i2c);
758+ usleep_range(100, 200);
759+ }
760+ return time_before(jiffies, time_left);
761+}
762+
714763 static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c,
715764 struct i2c_msg *msgs, int stop)
716765 {
@@ -725,8 +774,13 @@ static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c, · 8 unmodified lines
725774
726775 exynos5_i2c_message_start(i2c, stop);
727776
728− timeout = wait_for_completion_timeout(&i2c->msg_complete,
729− EXYNOS5_I2C_TIMEOUT);
777+ if (!i2c->atomic)
778+ timeout = wait_for_completion_timeout(&i2c->msg_complete,
779+ EXYNOS5_I2C_TIMEOUT);
780+ else
781+ timeout = exynos5_i2c_poll_irqs_timeout(i2c,
782+ EXYNOS5_I2C_TIMEOUT);
783+
730784 if (timeout == 0)
731785 ret = -ETIMEDOUT;
732786 else
@@ -777,6 +831,21 @@ err_pclk: · 44 unmodified lines
777831 return ret ?: num;
778832 }
779833
834+static int exynos5_i2c_xfer_atomic(struct i2c_adapter *adap,
835+ struct i2c_msg *msgs, int num)
836+{
837+ struct exynos5_i2c *i2c = adap->algo_data;
838+ int ret;
839+
840+ disable_irq(i2c->irq);
841+ i2c->atomic = true;
842+ ret = exynos5_i2c_xfer(adap, msgs, num);
843+ i2c->atomic = false;
844+ enable_irq(i2c->irq);
845+
846+ return ret;
847+}
848+
780849 static u32 exynos5_i2c_func(struct i2c_adapter *adap)
781850 {
782851 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
@@ -784,6 +853,7 @@ static u32 exynos5_i2c_func(struct i2c_adapter *adap) · 1 unmodified line
784853
785854 static const struct i2c_algorithm exynos5_i2c_algorithm = {
786855 .master_xfer = exynos5_i2c_xfer,
856+ .master_xfer_atomic = exynos5_i2c_xfer_atomic,
787857 .functionality = exynos5_i2c_func,
788858 };
789859
drivers/i2c/busses/i2c-gpio.c+1−6
@@ -263,15 +263,10 @@ static void i2c_gpio_fault_injector_init(struct platform_device *pdev) · 262 unmodified lines
263263 * 'fault-injector' dir there. Until then, we have a global dir with
264264 * all adapters as subdirs.
265265 */
266− if (!i2c_gpio_debug_dir) {
266+ if (!i2c_gpio_debug_dir)
267267 i2c_gpio_debug_dir = debugfs_create_dir("i2c-fault-injector", NULL);
268− if (!i2c_gpio_debug_dir)
269− return;
270− }
271268
272269 priv->debug_dir = debugfs_create_dir(pdev->name, i2c_gpio_debug_dir);
273− if (!priv->debug_dir)
274− return;
275270
276271 init_completion(&priv->scl_irq_completion);
277272
drivers/i2c/busses/i2c-i801.c+42−68
@@ -79,6 +79,7 @@ · 78 unmodified lines
7979 * Meteor Lake-P (SOC) 0x7e22 32 hard yes yes yes
8080 * Meteor Lake SoC-S (SOC) 0xae22 32 hard yes yes yes
8181 * Meteor Lake PCH-S (PCH) 0x7f23 32 hard yes yes yes
82+ * Birch Stream (SOC) 0x5796 32 hard yes yes yes
8283 *
8384 * Features supported by this driver:
8485 * Software PEC no
@@ -231,6 +232,7 @@ · 146 unmodified lines
231232 #define PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS 0x4da3
232233 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_P_SMBUS 0x51a3
233234 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_M_SMBUS 0x54a3
235+#define PCI_DEVICE_ID_INTEL_BIRCH_STREAM_SMBUS 0x5796
234236 #define PCI_DEVICE_ID_INTEL_BROXTON_SMBUS 0x5ad4
235237 #define PCI_DEVICE_ID_INTEL_RAPTOR_LAKE_S_SMBUS 0x7a23
236238 #define PCI_DEVICE_ID_INTEL_ALDER_LAKE_S_SMBUS 0x7aa3
@@ -285,7 +287,6 @@ struct i801_priv { · 48 unmodified lines
285287 u8 *data;
286288
287289 #if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI
288− const struct i801_mux_config *mux_drvdata;
289290 struct platform_device *mux_pdev;
290291 struct gpiod_lookup_table *lookup;
291292 #endif
@@ -293,10 +294,9 @@ struct i801_priv { · 1 unmodified line
293294
294295 /*
295296 * If set to true the host controller registers are reserved for
296− * ACPI AML use. Protected by acpi_lock.
297+ * ACPI AML use.
297298 */
298299 bool acpi_reserved;
299− struct mutex acpi_lock;
300300 };
301301
302302 #define FEATURE_SMBUS_PEC BIT(0)
@@ -679,15 +679,11 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, · 376 unmodified lines
679679 return result ? priv->status : -ETIMEDOUT;
680680 }
681681
682− for (i = 1; i <= len; i++) {
683− if (i == len && read_write == I2C_SMBUS_READ)
684− smbcmd |= SMBHSTCNT_LAST_BYTE;
685− outb_p(smbcmd, SMBHSTCNT(priv));
686−
687− if (i == 1)
688− outb_p(inb(SMBHSTCNT(priv)) | SMBHSTCNT_START,
689− SMBHSTCNT(priv));
682+ if (len == 1 && read_write == I2C_SMBUS_READ)
683+ smbcmd |= SMBHSTCNT_LAST_BYTE;
684+ outb_p(smbcmd | SMBHSTCNT_START, SMBHSTCNT(priv));
690685
686+ for (i = 1; i <= len; i++) {
691687 status = i801_wait_byte_done(priv);
692688 if (status)
693689 return status;
@@ -710,9 +706,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, · 16 unmodified lines
710706 data->block[0] = len;
711707 }
712708
713− /* Retrieve/store value in SMBBLKDAT */
714− if (read_write == I2C_SMBUS_READ)
709+ if (read_write == I2C_SMBUS_READ) {
715710 data->block[i] = inb_p(SMBBLKDAT(priv));
711+ if (i == len - 1)
712+ outb_p(smbcmd | SMBHSTCNT_LAST_BYTE, SMBHSTCNT(priv));
713+ }
714+
716715 if (read_write == I2C_SMBUS_WRITE && i+1 <= len)
717716 outb_p(data->block[i+1], SMBBLKDAT(priv));
718717
@@ -875,11 +874,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, · 156 unmodified lines
875874 int hwpec, ret;
876875 struct i801_priv *priv = i2c_get_adapdata(adap);
877876
878− mutex_lock(&priv->acpi_lock);
879− if (priv->acpi_reserved) {
880− mutex_unlock(&priv->acpi_lock);
877+ if (priv->acpi_reserved)
881878 return -EBUSY;
882− }
883879
884880 pm_runtime_get_sync(&priv->pci_dev->dev);
885881
@@ -920,7 +916,6 @@ out: · 34 unmodified lines
920916
921917 pm_runtime_mark_last_busy(&priv->pci_dev->dev);
922918 pm_runtime_put_autosuspend(&priv->pci_dev->dev);
923− mutex_unlock(&priv->acpi_lock);
924919 return ret;
925920 }
926921
@@ -1044,6 +1039,7 @@ static const struct pci_device_id i801_ids[] = { · 117 unmodified lines
10441039 { PCI_DEVICE_DATA(INTEL, METEOR_LAKE_P_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
10451040 { PCI_DEVICE_DATA(INTEL, METEOR_LAKE_SOC_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
10461041 { PCI_DEVICE_DATA(INTEL, METEOR_LAKE_PCH_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
1042+ { PCI_DEVICE_DATA(INTEL, BIRCH_STREAM_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) },
10471043 { 0, }
10481044 };
10491045
@@ -1288,7 +1284,7 @@ static void i801_probe_optional_slaves(struct i801_priv *priv) · 238 unmodified lines
12881284
12891285 /* Instantiate SPD EEPROMs unless the SMBus is multiplexed */
12901286 #if IS_ENABLED(CONFIG_I2C_MUX_GPIO)
1291− if (!priv->mux_drvdata)
1287+ if (!priv->mux_pdev)
12921288 #endif
12931289 i2c_register_spd(&priv->adapter);
12941290 }
@@ -1390,11 +1386,14 @@ static void i801_add_mux(struct i801_priv *priv) · 95 unmodified lines
13901386 const struct i801_mux_config *mux_config;
13911387 struct i2c_mux_gpio_platform_data gpio_data;
13921388 struct gpiod_lookup_table *lookup;
1389+ const struct dmi_system_id *id;
13931390 int i;
13941391
1395− if (!priv->mux_drvdata)
1392+ id = dmi_first_match(mux_dmi_table);
1393+ if (!id)
13961394 return;
1397− mux_config = priv->mux_drvdata;
1395+
1396+ mux_config = id->driver_data;
13981397
13991398 /* Prepare the platform data */
14001399 memset(&gpio_data, 0, sizeof(struct i2c_mux_gpio_platform_data));
@@ -1438,35 +1437,9 @@ static void i801_del_mux(struct i801_priv *priv) · 37 unmodified lines
14381437 platform_device_unregister(priv->mux_pdev);
14391438 gpiod_remove_lookup_table(priv->lookup);
14401439 }
1441−
1442−static unsigned int i801_get_adapter_class(struct i801_priv *priv)
1443−{
1444− const struct dmi_system_id *id;
1445− const struct i801_mux_config *mux_config;
1446− unsigned int class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
1447− int i;
1448−
1449− id = dmi_first_match(mux_dmi_table);
1450− if (id) {
1451− /* Remove branch classes from trunk */
1452− mux_config = id->driver_data;
1453− for (i = 0; i < mux_config->n_values; i++)
1454− class &= ~mux_config->classes[i];
1455−
1456− /* Remember for later */
1457− priv->mux_drvdata = mux_config;
1458− }
1459−
1460− return class;
1461−}
14621440 #else
14631441 static inline void i801_add_mux(struct i801_priv *priv) { }
14641442 static inline void i801_del_mux(struct i801_priv *priv) { }
1465−
1466−static inline unsigned int i801_get_adapter_class(struct i801_priv *priv)
1467−{
1468− return I2C_CLASS_HWMON | I2C_CLASS_SPD;
1469−}
14701443 #endif
14711444
14721445 static struct platform_device *
@@ -1572,7 +1545,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits, · 99 unmodified lines
15721545 * further access from the driver itself. This device is now owned
15731546 * by the system firmware.
15741547 */
1575− mutex_lock(&priv->acpi_lock);
1548+ i2c_lock_bus(&priv->adapter, I2C_LOCK_SEGMENT);
15761549
15771550 if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) {
15781551 priv->acpi_reserved = true;
@@ -1592,7 +1565,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits, · 13 unmodified lines
15921565 else
15931566 status = acpi_os_write_port(address, (u32)*value, bits);
15941567
1595− mutex_unlock(&priv->acpi_lock);
1568+ i2c_unlock_bus(&priv->adapter, I2C_LOCK_SEGMENT);
15961569
15971570 return status;
15981571 }
@@ -1630,6 +1603,12 @@ static void i801_setup_hstcfg(struct i801_priv *priv) · 31 unmodified lines
16301603 pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hstcfg);
16311604 }
16321605
1606+static void i801_restore_regs(struct i801_priv *priv)
1607+{
1608+ outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
1609+ pci_write_config_byte(priv->pci_dev, SMBHSTCFG, priv->original_hstcfg);
1610+}
1611+
16331612 static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
16341613 {
16351614 int err, i;
@@ -1641,12 +1620,11 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 5 unmodified lines
16411620
16421621 i2c_set_adapdata(&priv->adapter, priv);
16431622 priv->adapter.owner = THIS_MODULE;
1644− priv->adapter.class = i801_get_adapter_class(priv);
1623+ priv->adapter.class = I2C_CLASS_HWMON;
16451624 priv->adapter.algo = &smbus_algorithm;
16461625 priv->adapter.dev.parent = &dev->dev;
1647− ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&dev->dev));
1626+ acpi_use_parent_companion(&priv->adapter.dev);
16481627 priv->adapter.retries = 3;
1649− mutex_init(&priv->acpi_lock);
16501628
16511629 priv->pci_dev = dev;
16521630 priv->features = id->driver_data;
@@ -1756,6 +1734,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 103 unmodified lines
17561734 if (err) {
17571735 platform_device_unregister(priv->tco_pdev);
17581736 i801_acpi_remove(priv);
1737+ i801_restore_regs(priv);
17591738 return err;
17601739 }
17611740
@@ -1780,12 +1759,10 @@ static void i801_remove(struct pci_dev *dev) · 18 unmodified lines
17801759 {
17811760 struct i801_priv *priv = pci_get_drvdata(dev);
17821761
1783− outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
17841762 i801_disable_host_notify(priv);
17851763 i801_del_mux(priv);
17861764 i2c_del_adapter(&priv->adapter);
17871765 i801_acpi_remove(priv);
1788− pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
17891766
17901767 platform_device_unregister(priv->tco_pdev);
17911768
@@ -1793,6 +1770,8 @@ static void i801_remove(struct pci_dev *dev) · 1 unmodified line
17931770 if (!priv->acpi_reserved)
17941771 pm_runtime_get_noresume(&dev->dev);
17951772
1773+ i801_restore_regs(priv);
1774+
17961775 /*
17971776 * do not call pci_disable_device(dev) since it can cause hard hangs on
17981777 * some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010)
@@ -1803,18 +1782,18 @@ static void i801_shutdown(struct pci_dev *dev) · 4 unmodified lines
18031782 {
18041783 struct i801_priv *priv = pci_get_drvdata(dev);
18051784
1806− /* Restore config registers to avoid hard hang on some systems */
1807− outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
18081785 i801_disable_host_notify(priv);
1809− pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
1786+ /* Restore config registers to avoid hard hang on some systems */
1787+ i801_restore_regs(priv);
18101788 }
18111789
18121790 static int i801_suspend(struct device *dev)
18131791 {
18141792 struct i801_priv *priv = dev_get_drvdata(dev);
18151793
1816− outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
1817− pci_write_config_byte(priv->pci_dev, SMBHSTCFG, priv->original_hstcfg);
1794+ i2c_mark_adapter_suspended(&priv->adapter);
1795+ i801_restore_regs(priv);
1796+
18181797 return 0;
18191798 }
18201799
@@ -1824,6 +1803,7 @@ static int i801_resume(struct device *dev) · 3 unmodified lines
18241803
18251804 i801_setup_hstcfg(priv);
18261805 i801_enable_host_notify(&priv->adapter);
1806+ i2c_mark_adapter_resumed(&priv->adapter);
18271807
18281808 return 0;
18291809 }
@@ -1842,16 +1822,11 @@ static struct pci_driver i801_driver = { · 12 unmodified lines
18421822 },
18431823 };
18441824
1845−static int __init i2c_i801_init(void)
1825+static int __init i2c_i801_init(struct pci_driver *drv)
18461826 {
18471827 if (dmi_name_in_vendors("FUJITSU"))
18481828 input_apanel_init();
1849− return pci_register_driver(&i801_driver);
1850−}
1851−
1852−static void __exit i2c_i801_exit(void)
1853−{
1854− pci_unregister_driver(&i801_driver);
1829+ return pci_register_driver(drv);
18551830 }
18561831
18571832 MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>");
@@ -1859,5 +1834,4 @@ MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>"); · 1 unmodified line
18591834 MODULE_DESCRIPTION("I801 SMBus driver");
18601835 MODULE_LICENSE("GPL");
18611836
1862−module_init(i2c_i801_init);
1863−module_exit(i2c_i801_exit);
1837+module_driver(i801_driver, i2c_i801_init, pci_unregister_driver);
drivers/i2c/busses/i2c-mt65xx.c+8−4
@@ -1442,15 +1442,19 @@ static int mtk_i2c_probe(struct platform_device *pdev) · 1441 unmodified lines
14421442 if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk))
14431443 return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_ARB].clk);
14441444
1445+ i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get_optional(&pdev->dev, "pmic");
1446+ if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) {
1447+ dev_err(&pdev->dev, "cannot get pmic clock\n");
1448+ return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk);
1449+ }
1450+
14451451 if (i2c->have_pmic) {
1446− i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = devm_clk_get(&pdev->dev, "pmic");
1447− if (IS_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk)) {
1452+ if (!i2c->clocks[I2C_MT65XX_CLK_PMIC].clk) {
14481453 dev_err(&pdev->dev, "cannot get pmic clock\n");
1449− return PTR_ERR(i2c->clocks[I2C_MT65XX_CLK_PMIC].clk);
1454+ return -ENODEV;
14501455 }
14511456 speed_clk = I2C_MT65XX_CLK_PMIC;
14521457 } else {
1453− i2c->clocks[I2C_MT65XX_CLK_PMIC].clk = NULL;
14541458 speed_clk = I2C_MT65XX_CLK_MAIN;
14551459 }
14561460
drivers/i2c/busses/i2c-mv64xxx.c+5−6
@@ -19,11 +19,10 @@ · 18 unmodified lines
1919 #include <linux/platform_device.h>
2020 #include <linux/pinctrl/consumer.h>
2121 #include <linux/pm_runtime.h>
22+#include <linux/property.h>
2223 #include <linux/reset.h>
2324 #include <linux/io.h>
2425 #include <linux/of.h>
25−#include <linux/of_device.h>
26−#include <linux/of_irq.h>
2726 #include <linux/clk.h>
2827 #include <linux/err.h>
2928 #include <linux/delay.h>
@@ -859,7 +858,7 @@ static int · 829 unmodified lines
859858 mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
860859 struct device *dev)
861860 {
862− const struct of_device_id *device;
861+ const struct mv64xxx_i2c_regs *data;
863862 struct device_node *np = dev->of_node;
864863 u32 bus_freq, tclk;
865864 int rc = 0;
@@ -897,11 +896,11 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, · 31 unmodified lines
897896 */
898897 drv_data->adapter.timeout = HZ;
899898
900− device = of_match_device(mv64xxx_i2c_of_match_table, dev);
901− if (!device)
899+ data = device_get_match_data(dev);
900+ if (!data)
902901 return -ENODEV;
903902
904− memcpy(&drv_data->reg_offsets, device->data, sizeof(drv_data->reg_offsets));
903+ memcpy(&drv_data->reg_offsets, data, sizeof(drv_data->reg_offsets));
905904
906905 /*
907906 * For controllers embedded in new SoCs activate the
drivers/i2c/busses/i2c-omap.c+3−5
@@ -25,11 +25,11 @@ · 24 unmodified lines
2525 #include <linux/clk.h>
2626 #include <linux/io.h>
2727 #include <linux/of.h>
28−#include <linux/of_device.h>
2928 #include <linux/slab.h>
3029 #include <linux/platform_data/i2c-omap.h>
3130 #include <linux/pm_runtime.h>
3231 #include <linux/pinctrl/consumer.h>
32+#include <linux/property.h>
3333
3434 /* I2C controller revisions */
3535 #define OMAP_I2C_OMAP1_REV_2 0x20
@@ -1358,7 +1358,6 @@ omap_i2c_probe(struct platform_device *pdev) · 1322 unmodified lines
13581358 const struct omap_i2c_bus_platform_data *pdata =
13591359 dev_get_platdata(&pdev->dev);
13601360 struct device_node *node = pdev->dev.of_node;
1361− const struct of_device_id *match;
13621361 int irq;
13631362 int r;
13641363 u32 rev;
@@ -1376,11 +1375,10 @@ omap_i2c_probe(struct platform_device *pdev) · 11 unmodified lines
13761375 if (IS_ERR(omap->base))
13771376 return PTR_ERR(omap->base);
13781377
1379− match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev);
1380− if (match) {
1378+ if (pdev->dev.of_node) {
13811379 u32 freq = I2C_MAX_STANDARD_MODE_FREQ;
13821380
1383− pdata = match->data;
1381+ pdata = device_get_match_data(&pdev->dev);
13841382 omap->flags = pdata->flags;
13851383
13861384 of_property_read_u32(node, "clock-frequency", &freq);
drivers/i2c/busses/i2c-powermac.c+1−1
@@ -231,7 +231,7 @@ static void i2c_powermac_create_one(struct i2c_adapter *adap, · 230 unmodified lines
231231 struct i2c_board_info info = {};
232232 struct i2c_client *newdev;
233233
234− strncpy(info.type, type, sizeof(info.type));
234+ strscpy(info.type, type, sizeof(info.type));
235235 info.addr = addr;
236236 newdev = i2c_new_client_device(adap, &info);
237237 if (IS_ERR(newdev))
drivers/i2c/busses/i2c-pxa.c+3−4
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include <linux/pinctrl/consumer.h>
3333 #include <linux/platform_device.h>
3434 #include <linux/platform_data/i2c-pxa.h>
35+#include <linux/property.h>
3536 #include <linux/slab.h>
3637
3738 /* I2C register field definitions */
@@ -1252,10 +1253,8 @@ static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c, · 1214 unmodified lines
12521253 enum pxa_i2c_types *i2c_types)
12531254 {
12541255 struct device_node *np = pdev->dev.of_node;
1255− const struct of_device_id *of_id =
1256− of_match_device(i2c_pxa_dt_ids, &pdev->dev);
12571256
1258− if (!of_id)
1257+ if (!pdev->dev.of_node)
12591258 return 1;
12601259
12611260 /* For device tree we always use the dynamic or alias-assigned ID */
@@ -1264,7 +1263,7 @@ static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c, · 2 unmodified lines
12641263 i2c->use_pio = of_property_read_bool(np, "mrvl,i2c-polling");
12651264 i2c->fast_mode = of_property_read_bool(np, "mrvl,i2c-fast-mode");
12661265
1267− *i2c_types = (enum pxa_i2c_types)(of_id->data);
1266+ *i2c_types = (enum pxa_i2c_types)device_get_match_data(&pdev->dev);
12681267
12691268 return 0;
12701269 }
drivers/i2c/busses/i2c-qcom-geni.c+1−0
@@ -722,6 +722,7 @@ static const struct i2c_algorithm geni_i2c_algo = { · 721 unmodified lines
722722 #ifdef CONFIG_ACPI
723723 static const struct acpi_device_id geni_i2c_acpi_match[] = {
724724 { "QCOM0220"},
725+ { "QCOM0411" },
725726 { },
726727 };
727728 MODULE_DEVICE_TABLE(acpi, geni_i2c_acpi_match);
drivers/i2c/busses/i2c-rcar.c+113−67
@@ -41,6 +41,10 @@ · 40 unmodified lines
4141 #define ICSAR 0x1C /* slave address */
4242 #define ICMAR 0x20 /* master address */
4343 #define ICRXTX 0x24 /* data port */
44+#define ICCCR2 0x28 /* Clock control 2 */
45+#define ICMPR 0x2C /* SCL mask control */
46+#define ICHPR 0x30 /* SCL HIGH control */
47+#define ICLPR 0x34 /* SCL LOW control */
4448 #define ICFBSCR 0x38 /* first bit setup cycle (Gen3) */
4549 #define ICDMAER 0x3c /* DMA enable (Gen3) */
4650
@@ -84,11 +88,25 @@ · 37 unmodified lines
8488 #define RMDMAE BIT(1) /* DMA Master Received Enable */
8589 #define TMDMAE BIT(0) /* DMA Master Transmitted Enable */
8690
91+/* ICCCR2 */
92+#define CDFD BIT(2) /* CDF Disable */
93+#define HLSE BIT(1) /* HIGH/LOW Separate Control Enable */
94+#define SME BIT(0) /* SCL Mask Enable */
95+
8796 /* ICFBSCR */
8897 #define TCYC17 0x0f /* 17*Tcyc delay 1st bit between SDA and SCL */
8998
9099 #define RCAR_MIN_DMA_LEN 8
91100
101+/* SCL low/high ratio 5:4 to meet all I2C timing specs (incl safety margin) */
102+#define RCAR_SCLD_RATIO 5
103+#define RCAR_SCHD_RATIO 4
104+/*
105+ * SMD should be smaller than SCLD/SCHD and is always around 20 in the docs.
106+ * Thus, we simply use 20 which works for low and high speeds.
107+ */
108+#define RCAR_DEFAULT_SMD 20
109+
92110 #define RCAR_BUS_PHASE_START (MDBS | MIE | ESG)
93111 #define RCAR_BUS_PHASE_DATA (MDBS | MIE)
94112 #define RCAR_BUS_PHASE_STOP (MDBS | MIE | FSB)
@@ -128,6 +146,8 @@ struct rcar_i2c_priv { · 33 unmodified lines
128146
129147 int pos;
130148 u32 icccr;
149+ u16 schd;
150+ u16 scld;
131151 u8 recovery_icmcr; /* protected by adapter lock */
132152 enum rcar_i2c_type devtype;
133153 struct i2c_client *slave;
@@ -216,11 +236,16 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv) · 82 unmodified lines
216236 rcar_i2c_write(priv, ICMCR, MDBS);
217237 rcar_i2c_write(priv, ICMSR, 0);
218238 /* start clock */
219− rcar_i2c_write(priv, ICCCR, priv->icccr);
220−
221− if (priv->devtype == I2C_RCAR_GEN3)
239+ if (priv->devtype < I2C_RCAR_GEN3) {
240+ rcar_i2c_write(priv, ICCCR, priv->icccr);
241+ } else {
242+ rcar_i2c_write(priv, ICCCR2, CDFD | HLSE | SME);
243+ rcar_i2c_write(priv, ICCCR, priv->icccr);
244+ rcar_i2c_write(priv, ICMPR, RCAR_DEFAULT_SMD);
245+ rcar_i2c_write(priv, ICHPR, priv->schd);
246+ rcar_i2c_write(priv, ICLPR, priv->scld);
222247 rcar_i2c_write(priv, ICFBSCR, TCYC17);
223−
248+ }
224249 }
225250
226251 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
@@ -241,7 +266,7 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) · 14 unmodified lines
241266
242267 static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
243268 {
244− u32 scgd, cdf, round, ick, sum, scl, cdf_width;
269+ u32 cdf, round, ick, sum, scl, cdf_width;
245270 unsigned long rate;
246271 struct device *dev = rcar_i2c_priv_to_dev(priv);
247272 struct i2c_timings t = {
@@ -254,27 +279,17 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv) · 6 unmodified lines
254279 /* Fall back to previously used values if not supplied */
255280 i2c_parse_fw_timings(dev, &t, false);
256281
257− switch (priv->devtype) {
258− case I2C_RCAR_GEN1:
259− cdf_width = 2;
260− break;
261− case I2C_RCAR_GEN2:
262− case I2C_RCAR_GEN3:
263− cdf_width = 3;
264− break;
265− default:
266− dev_err(dev, "device type error\n");
267− return -EIO;
268− }
269−
270282 /*
271283 * calculate SCL clock
272284 * see
273− * ICCCR
285+ * ICCCR (and ICCCR2 for Gen3+)
274286 *
275287 * ick = clkp / (1 + CDF)
276288 * SCL = ick / (20 + SCGD * 8 + F[(ticf + tr + intd) * ick])
277289 *
290+ * for Gen3+:
291+ * SCL = clkp / (8 + SMD * 2 + SCLD + SCHD +F[(ticf + tr + intd) * clkp])
292+ *
278293 * ick : I2C internal clock < 20 MHz
279294 * ticf : I2C SCL falling time
280295 * tr : I2C SCL rising time
@@ -284,52 +299,82 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv) · 3 unmodified lines
284299 */
285300 rate = clk_get_rate(priv->clk);
286301 cdf = rate / 20000000;
287− if (cdf >= 1U << cdf_width) {
288− dev_err(dev, "Input clock %lu too high\n", rate);
289− return -EIO;
290− }
291− ick = rate / (cdf + 1);
302+ cdf_width = (priv->devtype == I2C_RCAR_GEN1) ? 2 : 3;
303+ if (cdf >= 1U << cdf_width)
304+ goto err_no_val;
305+
306+ /* On Gen3+, we use cdf only for the filters, not as a SCL divider */
307+ ick = rate / (priv->devtype < I2C_RCAR_GEN3 ? (cdf + 1) : 1);
292308
293309 /*
294− * it is impossible to calculate large scale
295− * number on u32. separate it
310+ * It is impossible to calculate a large scale number on u32. Separate it.
296311 *
297312 * F[(ticf + tr + intd) * ick] with sum = (ticf + tr + intd)
298313 * = F[sum * ick / 1000000000]
299314 * = F[(ick / 1000000) * sum / 1000]
300315 */
301316 sum = t.scl_fall_ns + t.scl_rise_ns + t.scl_int_delay_ns;
302− round = (ick + 500000) / 1000000 * sum;
303− round = (round + 500) / 1000;
317+ round = DIV_ROUND_CLOSEST(ick, 1000000);
318+ round = DIV_ROUND_CLOSEST(round * sum, 1000);
304319
305− /*
306− * SCL = ick / (20 + SCGD * 8 + F[(ticf + tr + intd) * ick])
307− *
308− * Calculation result (= SCL) should be less than
309− * bus_speed for hardware safety
310− *
311− * We could use something along the lines of
312− * div = ick / (bus_speed + 1) + 1;
313− * scgd = (div - 20 - round + 7) / 8;
314− * scl = ick / (20 + (scgd * 8) + round);
315− * (not fully verified) but that would get pretty involved
316− */
317− for (scgd = 0; scgd < 0x40; scgd++) {
318− scl = ick / (20 + (scgd * 8) + round);
319− if (scl <= t.bus_freq_hz)
320− goto scgd_find;
321− }
322− dev_err(dev, "it is impossible to calculate best SCL\n");
323− return -EIO;
320+ if (priv->devtype < I2C_RCAR_GEN3) {
321+ u32 scgd;
322+ /*
323+ * SCL = ick / (20 + 8 * SCGD + F[(ticf + tr + intd) * ick])
324+ * 20 + 8 * SCGD + F[...] = ick / SCL
325+ * SCGD = ((ick / SCL) - 20 - F[...]) / 8
326+ * Result (= SCL) should be less than bus_speed for hardware safety
327+ */
328+ scgd = DIV_ROUND_UP(ick, t.bus_freq_hz ?: 1);
329+ scgd = DIV_ROUND_UP(scgd - 20 - round, 8);
330+ scl = ick / (20 + 8 * scgd + round);
331+
332+ if (scgd > 0x3f)
333+ goto err_no_val;
324334
325−scgd_find:
326− dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n",
327− scl, t.bus_freq_hz, rate, round, cdf, scgd);
335+ dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u, SCGD: %u\n",
336+ scl, t.bus_freq_hz, rate, round, cdf, scgd);
328337
329− /* keep icccr value */
330− priv->icccr = scgd << cdf_width | cdf;
338+ priv->icccr = scgd << cdf_width | cdf;
339+ } else {
340+ u32 x, sum_ratio = RCAR_SCHD_RATIO + RCAR_SCLD_RATIO;
341+ /*
342+ * SCLD/SCHD ratio and SMD default value are explained above
343+ * where they are defined. With these definitions, we can compute
344+ * x as a base value for the SCLD/SCHD ratio:
345+ *
346+ * SCL = clkp / (8 + 2 * SMD + SCLD + SCHD + F[(ticf + tr + intd) * clkp])
347+ * SCL = clkp / (8 + 2 * RCAR_DEFAULT_SMD + RCAR_SCLD_RATIO * x
348+ * + RCAR_SCHD_RATIO * x + F[...])
349+ *
350+ * with: sum_ratio = RCAR_SCLD_RATIO + RCAR_SCHD_RATIO
351+ * and: smd = RCAR_DEFAULT_SMD
352+ *
353+ * SCL = clkp / (8 + 2 * smd + sum_ratio * x + F[...])
354+ * 8 + 2 * smd + sum_ratio * x + F[...] = clkp / SCL
355+ * x = ((clkp / SCL) - 8 - 2 * smd - F[...]) / sum_ratio
356+ */
357+ x = DIV_ROUND_UP(rate, t.bus_freq_hz ?: 1);
358+ x = DIV_ROUND_UP(x - 8 - 2 * RCAR_DEFAULT_SMD - round, sum_ratio);
359+ scl = rate / (8 + 2 * RCAR_DEFAULT_SMD + sum_ratio * x + round);
360+
361+ /* Bail out if values don't fit into 16 bit or SMD became too large */
362+ if (x * RCAR_SCLD_RATIO > 0xffff || RCAR_DEFAULT_SMD > x * RCAR_SCHD_RATIO)
363+ goto err_no_val;
364+
365+ priv->icccr = cdf;
366+ priv->schd = RCAR_SCHD_RATIO * x;
367+ priv->scld = RCAR_SCLD_RATIO * x;
368+
369+ dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u SCHD %u SCLD %u\n",
370+ scl, t.bus_freq_hz, rate, round, cdf, priv->schd, priv->scld);
371+ }
331372
332373 return 0;
374+
375+err_no_val:
376+ dev_err(dev, "it is impossible to calculate best SCL\n");
377+ return -EINVAL;
333378 }
334379
335380 /*
@@ -843,12 +888,10 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, · 507 unmodified lines
843888
844889 /* Gen3 needs a reset before allowing RXDMA once */
845890 if (priv->devtype == I2C_RCAR_GEN3) {
846− priv->flags |= ID_P_NO_RXDMA;
847− if (!IS_ERR(priv->rstc)) {
848− ret = rcar_i2c_do_reset(priv);
849− if (ret == 0)
850− priv->flags &= ~ID_P_NO_RXDMA;
851− }
891+ priv->flags &= ~ID_P_NO_RXDMA;
892+ ret = rcar_i2c_do_reset(priv);
893+ if (ret)
894+ goto out;
852895 }
853896
854897 rcar_i2c_init(priv);
@@ -1099,15 +1142,6 @@ static int rcar_i2c_probe(struct platform_device *pdev) · 244 unmodified lines
10991142 irqhandler = rcar_i2c_gen2_irq;
11001143 }
11011144
1102− if (priv->devtype == I2C_RCAR_GEN3) {
1103− priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
1104− if (!IS_ERR(priv->rstc)) {
1105− ret = reset_control_status(priv->rstc);
1106− if (ret < 0)
1107− priv->rstc = ERR_PTR(-ENOTSUPP);
1108− }
1109− }
1110−
11111145 /* Stay always active when multi-master to keep arbitration working */
11121146 if (of_property_read_bool(dev->of_node, "multi-master"))
11131147 priv->flags |= ID_P_PM_BLOCKED;
@@ -1117,6 +1151,18 @@ static int rcar_i2c_probe(struct platform_device *pdev) · 3 unmodified lines
11171151 if (of_property_read_bool(dev->of_node, "smbus"))
11181152 priv->flags |= ID_P_HOST_NOTIFY;
11191153
1154+ if (priv->devtype == I2C_RCAR_GEN3) {
1155+ priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
1156+ if (IS_ERR(priv->rstc)) {
1157+ ret = PTR_ERR(priv->rstc);
1158+ goto out_pm_put;
1159+ }
1160+
1161+ ret = reset_control_status(priv->rstc);
1162+ if (ret < 0)
1163+ goto out_pm_put;
1164+ }
1165+
11201166 ret = platform_get_irq(pdev, 0);
11211167 if (ret < 0)
11221168 goto out_pm_put;
drivers/i2c/busses/i2c-riic.c+1−1
@@ -313,7 +313,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t) · 312 unmodified lines
313313 * frequency with only 62 clock ticks max (31 high, 31 low).
314314 * Aim for a duty of 60% LOW, 40% HIGH.
315315 */
316− total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz);
316+ total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1);
317317
318318 for (cks = 0; cks < 7; cks++) {
319319 /*
drivers/i2c/busses/i2c-s3c2410.c+3−4
@@ -133,7 +133,7 @@ static const struct platform_device_id s3c24xx_driver_ids[] = { · 132 unmodified lines
133133 };
134134 MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
135135
136−static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat);
136+static void i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat);
137137
138138 #ifdef CONFIG_OF
139139 static const struct of_device_id s3c24xx_i2c_match[] = {
@@ -377,11 +377,10 @@ static inline int is_msgend(struct s3c24xx_i2c *i2c) · 237 unmodified lines
377377 /*
378378 * process an interrupt and work out what to do
379379 */
380−static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
380+static void i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
381381 {
382382 unsigned long tmp;
383383 unsigned char byte;
384− int ret = 0;
385384
386385 switch (i2c->state) {
387386
@@ -544,7 +543,7 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) · 156 unmodified lines
544543 tmp &= ~S3C2410_IICCON_IRQPEND;
545544 writel(tmp, i2c->regs + S3C2410_IICCON);
546545 out:
547− return ret;
546+ return;
548547 }
549548
550549 /*
drivers/i2c/busses/i2c-stm32f4.c+10−22
@@ -783,23 +783,17 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) · 782 unmodified lines
783783 return -EINVAL;
784784 }
785785
786− i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
786+ i2c_dev->clk = devm_clk_get_enabled(&pdev->dev, NULL);
787787 if (IS_ERR(i2c_dev->clk)) {
788− dev_err(&pdev->dev, "Error: Missing controller clock\n");
788+ dev_err(&pdev->dev, "Failed to enable clock\n");
789789 return PTR_ERR(i2c_dev->clk);
790790 }
791− ret = clk_prepare_enable(i2c_dev->clk);
792− if (ret) {
793− dev_err(i2c_dev->dev, "Failed to prepare_enable clock\n");
794− return ret;
795− }
796791
797792 rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
798− if (IS_ERR(rst)) {
799− ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
800− "Error: Missing reset ctrl\n");
801− goto clk_free;
802− }
793+ if (IS_ERR(rst))
794+ return dev_err_probe(&pdev->dev, PTR_ERR(rst),
795+ "Error: Missing reset ctrl\n");
796+
803797 reset_control_assert(rst);
804798 udelay(2);
805799 reset_control_deassert(rst);
@@ -816,7 +810,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) · 10 unmodified lines
816810 if (ret) {
817811 dev_err(&pdev->dev, "Failed to request irq event %i\n",
818812 irq_event);
819− goto clk_free;
813+ return ret;
820814 }
821815
822816 ret = devm_request_irq(&pdev->dev, irq_error, stm32f4_i2c_isr_error, 0,
@@ -824,12 +818,12 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) · 1 unmodified line
824818 if (ret) {
825819 dev_err(&pdev->dev, "Failed to request irq error %i\n",
826820 irq_error);
827− goto clk_free;
821+ return ret;
828822 }
829823
830824 ret = stm32f4_i2c_hw_config(i2c_dev);
831825 if (ret)
832− goto clk_free;
826+ return ret;
833827
834828 adap = &i2c_dev->adap;
835829 i2c_set_adapdata(adap, i2c_dev);
@@ -845,7 +839,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) · 9 unmodified lines
845839
846840 ret = i2c_add_adapter(adap);
847841 if (ret)
848− goto clk_free;
842+ return ret;
849843
850844 platform_set_drvdata(pdev, i2c_dev);
851845
@@ -854,10 +848,6 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) · 2 unmodified lines
854848 dev_info(i2c_dev->dev, "STM32F4 I2C driver registered\n");
855849
856850 return 0;
857−
858−clk_free:
859− clk_disable_unprepare(i2c_dev->clk);
860− return ret;
861851 }
862852
863853 static void stm32f4_i2c_remove(struct platform_device *pdev)
@@ -865,8 +855,6 @@ static void stm32f4_i2c_remove(struct platform_device *pdev) · 1 unmodified line
865855 struct stm32f4_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
866856
867857 i2c_del_adapter(&i2c_dev->adap);
868−
869− clk_unprepare(i2c_dev->clk);
870858 }
871859
872860 static const struct of_device_id stm32f4_i2c_match[] = {
drivers/i2c/busses/i2c-stm32f7.c+60−29
@@ -325,6 +325,7 @@ struct stm32f7_i2c_alert { · 324 unmodified lines
325325 * @dnf_dt: value of digital filter requested via dt
326326 * @dnf: value of digital filter to apply
327327 * @alert: SMBus alert specific data
328+ * @atomic: boolean indicating that current transfer is atomic
328329 */
329330 struct stm32f7_i2c_dev {
330331 struct i2c_adapter adap;
@@ -357,6 +358,7 @@ struct stm32f7_i2c_dev { · 26 unmodified lines
357358 u32 dnf_dt;
358359 u32 dnf;
359360 struct stm32f7_i2c_alert *alert;
361+ bool atomic;
360362 };
361363
362364 /*
@@ -915,7 +917,8 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev, · 552 unmodified lines
915917
916918 /* Configure DMA or enable RX/TX interrupt */
917919 i2c_dev->use_dma = false;
918− if (i2c_dev->dma && f7_msg->count >= STM32F7_I2C_DMA_LEN_MIN) {
920+ if (i2c_dev->dma && f7_msg->count >= STM32F7_I2C_DMA_LEN_MIN
921+ && !i2c_dev->atomic) {
919922 ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma,
920923 msg->flags & I2C_M_RD,
921924 f7_msg->count, f7_msg->buf,
@@ -939,6 +942,9 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev, · 17 unmodified lines
939942 cr1 |= STM32F7_I2C_CR1_TXDMAEN;
940943 }
941944
945+ if (i2c_dev->atomic)
946+ cr1 &= ~STM32F7_I2C_ALL_IRQ_MASK; /* Disable all interrupts */
947+
942948 /* Configure Start/Repeated Start */
943949 cr2 |= STM32F7_I2C_CR2_START;
944950
@@ -1673,7 +1679,22 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data) · 728 unmodified lines
16731679 return IRQ_HANDLED;
16741680 }
16751681
1676−static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,
1682+static int stm32f7_i2c_wait_polling(struct stm32f7_i2c_dev *i2c_dev)
1683+{
1684+ ktime_t timeout = ktime_add_ms(ktime_get(), i2c_dev->adap.timeout);
1685+
1686+ while (ktime_compare(ktime_get(), timeout) < 0) {
1687+ udelay(5);
1688+ stm32f7_i2c_isr_event(0, i2c_dev);
1689+
1690+ if (completion_done(&i2c_dev->complete))
1691+ return 1;
1692+ }
1693+
1694+ return 0;
1695+}
1696+
1697+static int stm32f7_i2c_xfer_core(struct i2c_adapter *i2c_adap,
16771698 struct i2c_msg msgs[], int num)
16781699 {
16791700 struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap);
@@ -1697,8 +1718,12 @@ static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap, · 17 unmodified lines
16971718
16981719 stm32f7_i2c_xfer_msg(i2c_dev, msgs);
16991720
1700− time_left = wait_for_completion_timeout(&i2c_dev->complete,
1701− i2c_dev->adap.timeout);
1721+ if (!i2c_dev->atomic)
1722+ time_left = wait_for_completion_timeout(&i2c_dev->complete,
1723+ i2c_dev->adap.timeout);
1724+ else
1725+ time_left = stm32f7_i2c_wait_polling(i2c_dev);
1726+
17021727 ret = f7_msg->result;
17031728 if (ret) {
17041729 if (i2c_dev->use_dma)
@@ -1730,6 +1755,24 @@ pm_free: · 25 unmodified lines
17301755 return (ret < 0) ? ret : num;
17311756 }
17321757
1758+static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,
1759+ struct i2c_msg msgs[], int num)
1760+{
1761+ struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap);
1762+
1763+ i2c_dev->atomic = false;
1764+ return stm32f7_i2c_xfer_core(i2c_adap, msgs, num);
1765+}
1766+
1767+static int stm32f7_i2c_xfer_atomic(struct i2c_adapter *i2c_adap,
1768+ struct i2c_msg msgs[], int num)
1769+{
1770+ struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap);
1771+
1772+ i2c_dev->atomic = true;
1773+ return stm32f7_i2c_xfer_core(i2c_adap, msgs, num);
1774+}
1775+
17331776 static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
17341777 unsigned short flags, char read_write,
17351778 u8 command, int size,
@@ -2098,6 +2141,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap) · 362 unmodified lines
20982141
20992142 static const struct i2c_algorithm stm32f7_i2c_algo = {
21002143 .master_xfer = stm32f7_i2c_xfer,
2144+ .master_xfer_atomic = stm32f7_i2c_xfer_atomic,
21012145 .smbus_xfer = stm32f7_i2c_smbus_xfer,
21022146 .functionality = stm32f7_i2c_func,
21032147 .reg_slave = stm32f7_i2c_reg_slave,
@@ -2134,23 +2178,16 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) · 30 unmodified lines
21342178 i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
21352179 "wakeup-source");
21362180
2137− i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
2181+ i2c_dev->clk = devm_clk_get_enabled(&pdev->dev, NULL);
21382182 if (IS_ERR(i2c_dev->clk))
21392183 return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->clk),
2140− "Failed to get controller clock\n");
2141−
2142− ret = clk_prepare_enable(i2c_dev->clk);
2143− if (ret) {
2144− dev_err(&pdev->dev, "Failed to prepare_enable clock\n");
2145− return ret;
2146− }
2184+ "Failed to enable controller clock\n");
21472185
21482186 rst = devm_reset_control_get(&pdev->dev, NULL);
2149− if (IS_ERR(rst)) {
2150− ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
2151− "Error: Missing reset ctrl\n");
2152− goto clk_free;
2153− }
2187+ if (IS_ERR(rst))
2188+ return dev_err_probe(&pdev->dev, PTR_ERR(rst),
2189+ "Error: Missing reset ctrl\n");
2190+
21542191 reset_control_assert(rst);
21552192 udelay(2);
21562193 reset_control_deassert(rst);
@@ -2165,7 +2202,7 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) · 8 unmodified lines
21652202 if (ret) {
21662203 dev_err(&pdev->dev, "Failed to request irq event %i\n",
21672204 irq_event);
2168− goto clk_free;
2205+ return ret;
21692206 }
21702207
21712208 ret = devm_request_irq(&pdev->dev, irq_error, stm32f7_i2c_isr_error, 0,
@@ -2173,29 +2210,28 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) · 1 unmodified line
21732210 if (ret) {
21742211 dev_err(&pdev->dev, "Failed to request irq error %i\n",
21752212 irq_error);
2176− goto clk_free;
2213+ return ret;
21772214 }
21782215
21792216 setup = of_device_get_match_data(&pdev->dev);
21802217 if (!setup) {
21812218 dev_err(&pdev->dev, "Can't get device data\n");
2182− ret = -ENODEV;
2183− goto clk_free;
2219+ return -ENODEV;
21842220 }
21852221 i2c_dev->setup = *setup;
21862222
21872223 ret = stm32f7_i2c_setup_timing(i2c_dev, &i2c_dev->setup);
21882224 if (ret)
2189− goto clk_free;
2225+ return ret;
21902226
21912227 /* Setup Fast mode plus if necessary */
21922228 if (i2c_dev->bus_rate > I2C_MAX_FAST_MODE_FREQ) {
21932229 ret = stm32f7_i2c_setup_fm_plus_bits(pdev, i2c_dev);
21942230 if (ret)
2195− goto clk_free;
2231+ return ret;
21962232 ret = stm32f7_i2c_write_fm_plus_bits(i2c_dev, true);
21972233 if (ret)
2198− goto clk_free;
2234+ return ret;
21992235 }
22002236
22012237 adap = &i2c_dev->adap;
@@ -2306,9 +2342,6 @@ clr_wakeup_capable: · 104 unmodified lines
23062342 fmp_clear:
23072343 stm32f7_i2c_write_fm_plus_bits(i2c_dev, false);
23082344
2309−clk_free:
2310− clk_disable_unprepare(i2c_dev->clk);
2311−
23122345 return ret;
23132346 }
23142347
@@ -2342,8 +2375,6 @@ static void stm32f7_i2c_remove(struct platform_device *pdev) · 27 unmodified lines
23422375 }
23432376
23442377 stm32f7_i2c_write_fm_plus_bits(i2c_dev, false);
2345−
2346− clk_disable_unprepare(i2c_dev->clk);
23472378 }
23482379
23492380 static int __maybe_unused stm32f7_i2c_runtime_suspend(struct device *dev)
drivers/i2c/busses/i2c-sun6i-p2wi.c+5−0
@@ -201,6 +201,11 @@ static int p2wi_probe(struct platform_device *pdev) · 200 unmodified lines
201201 return -EINVAL;
202202 }
203203
204+ if (clk_freq == 0) {
205+ dev_err(dev, "clock-frequency is set to 0 in DT\n");
206+ return -EINVAL;
207+ }
208+
204209 if (of_get_child_count(np) > 1) {
205210 dev_err(dev, "P2WI only supports one slave device\n");
206211 return -EINVAL;
drivers/i2c/i2c-atr.c+1−1
@@ -94,7 +94,7 @@ struct i2c_atr { · 93 unmodified lines
9494
9595 struct notifier_block i2c_nb;
9696
97− struct i2c_adapter *adapter[];
97+ struct i2c_adapter *adapter[] __counted_by(max_adapters);
9898 };
9999
100100 static struct i2c_atr_alias_pair *
drivers/i2c/i2c-core-base.c+13−6
@@ -931,8 +931,9 @@ int i2c_dev_irq_from_resources(const struct resource *resources, · 930 unmodified lines
931931 struct i2c_client *
932932 i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
933933 {
934− struct i2c_client *client;
935− int status;
934+ struct i2c_client *client;
935+ bool need_put = false;
936+ int status;
936937
937938 client = kzalloc(sizeof *client, GFP_KERNEL);
938939 if (!client)
@@ -970,7 +971,6 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf · 31 unmodified lines
970971 client->dev.fwnode = info->fwnode;
971972
972973 device_enable_async_suspend(&client->dev);
973− i2c_dev_set_name(adap, client, info);
974974
975975 if (info->swnode) {
976976 status = device_add_software_node(&client->dev, info->swnode);
@@ -982,6 +982,7 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf · 5 unmodified lines
982982 }
983983 }
984984
985+ i2c_dev_set_name(adap, client, info);
985986 status = device_register(&client->dev);
986987 if (status)
987988 goto out_remove_swnode;
@@ -993,6 +994,7 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf · 5 unmodified lines
993994
994995 out_remove_swnode:
995996 device_remove_software_node(&client->dev);
997+ need_put = true;
996998 out_err_put_of_node:
997999 of_node_put(info->of_node);
9981000 out_err:
@@ -1000,7 +1002,10 @@ out_err: · 1 unmodified line
10001002 "Failed to register i2c client %s at 0x%02x (%d)\n",
10011003 client->name, client->addr, status);
10021004 out_err_silent:
1003− kfree(client);
1005+ if (need_put)
1006+ put_device(&client->dev);
1007+ else
1008+ kfree(client);
10041009 return ERR_PTR(status);
10051010 }
10061011 EXPORT_SYMBOL_GPL(i2c_new_client_device);
@@ -1189,9 +1194,11 @@ static void i2c_adapter_dev_release(struct device *dev) · 182 unmodified lines
11891194 unsigned int i2c_adapter_depth(struct i2c_adapter *adapter)
11901195 {
11911196 unsigned int depth = 0;
1197+ struct device *parent;
11921198
1193− while ((adapter = i2c_parent_is_i2c_adapter(adapter)))
1194− depth++;
1199+ for (parent = adapter->dev.parent; parent; parent = parent->parent)
1200+ if (parent->type == &i2c_adapter_type)
1201+ depth++;
11951202
11961203 WARN_ONCE(depth >= MAX_LOCKDEP_SUBCLASSES,
11971204 "adapter depth exceeds lockdep subclass limit\n");
drivers/i2c/i2c-dev.c+9−9
@@ -636,7 +636,10 @@ static const struct file_operations i2cdev_fops = { · 635 unmodified lines
636636
637637 /* ------------------------------------------------------------------------- */
638638
639−static struct class *i2c_dev_class;
639+static const struct class i2c_dev_class = {
640+ .name = "i2c-dev",
641+ .dev_groups = i2c_groups,
642+};
640643
641644 static void i2cdev_dev_release(struct device *dev)
642645 {
@@ -665,7 +668,7 @@ static int i2cdev_attach_adapter(struct device *dev) · 22 unmodified lines
665668
666669 device_initialize(&i2c_dev->dev);
667670 i2c_dev->dev.devt = MKDEV(I2C_MAJOR, adap->nr);
668− i2c_dev->dev.class = i2c_dev_class;
671+ i2c_dev->dev.class = &i2c_dev_class;
669672 i2c_dev->dev.parent = &adap->dev;
670673 i2c_dev->dev.release = i2cdev_dev_release;
671674
@@ -751,12 +754,9 @@ static int __init i2c_dev_init(void) · 79 unmodified lines
751754 if (res)
752755 goto out;
753756
754− i2c_dev_class = class_create("i2c-dev");
755− if (IS_ERR(i2c_dev_class)) {
756− res = PTR_ERR(i2c_dev_class);
757+ res = class_register(&i2c_dev_class);
758+ if (res)
757759 goto out_unreg_chrdev;
758− }
759− i2c_dev_class->dev_groups = i2c_groups;
760760
761761 /* Keep track of adapters which will be added or removed later */
762762 res = bus_register_notifier(&i2c_bus_type, &i2cdev_notifier);
@@ -769,7 +769,7 @@ static int __init i2c_dev_init(void) · 6 unmodified lines
769769 return 0;
770770
771771 out_unreg_class:
772− class_destroy(i2c_dev_class);
772+ class_unregister(&i2c_dev_class);
773773 out_unreg_chrdev:
774774 unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS);
775775 out:
@@ -781,7 +781,7 @@ static void __exit i2c_dev_exit(void) · 5 unmodified lines
781781 {
782782 bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier);
783783 i2c_for_each_dev(NULL, i2c_dev_detach_adapter);
784− class_destroy(i2c_dev_class);
784+ class_unregister(&i2c_dev_class);
785785 unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS);
786786 }
787787
drivers/i2c/muxes/i2c-demux-pinctrl.c+6−6
@@ -32,7 +32,7 @@ struct i2c_demux_pinctrl_priv { · 31 unmodified lines
3232 const char *bus_name;
3333 struct i2c_adapter cur_adap;
3434 struct i2c_algorithm algo;
35− struct i2c_demux_pinctrl_chan chan[];
35+ struct i2c_demux_pinctrl_chan chan[] __counted_by(num_chan);
3636 };
3737
3838 static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
@@ -167,9 +167,9 @@ static ssize_t available_masters_show(struct device *dev, · 128 unmodified lines
167167 int count = 0, i;
168168
169169 for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++)
170− count += scnprintf(buf + count, PAGE_SIZE - count, "%d:%pOF%c",
171− i, priv->chan[i].parent_np,
172− i == priv->num_chan - 1 ? '\n' : ' ');
170+ count += sysfs_emit_at(buf, count, "%d:%pOF%c",
171+ i, priv->chan[i].parent_np,
172+ i == priv->num_chan - 1 ? '\n' : ' ');
173173
174174 return count;
175175 }
@@ -226,6 +226,8 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) · 50 unmodified lines
226226 if (!priv || !props)
227227 return -ENOMEM;
228228
229+ priv->num_chan = num_chan;
230+
229231 err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name);
230232 if (err)
231233 return err;
@@ -253,9 +255,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) · 21 unmodified lines
253255 of_changeset_update_property(&priv->chan[i].chgset, adap_np, &props[i]);
254256 }
255257
256− priv->num_chan = num_chan;
257258 priv->dev = &pdev->dev;
258−
259259 platform_set_drvdata(pdev, priv);
260260
261261 pm_runtime_no_callbacks(&pdev->dev);
drivers/i2c/muxes/i2c-mux-gpio.c+3−4
@@ -22,7 +22,7 @@ struct gpiomux { · 21 unmodified lines
2222 struct gpio_desc **gpios;
2323 };
2424
25−static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val)
25+static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned int val)
2626 {
2727 DECLARE_BITMAP(values, BITS_PER_TYPE(val));
2828
@@ -58,7 +58,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, · 29 unmodified lines
5858 struct device_node *adapter_np;
5959 struct i2c_adapter *adapter = NULL;
6060 struct fwnode_handle *child;
61− unsigned *values;
61+ unsigned int *values;
6262 int rc, i = 0;
6363
6464 if (is_of_node(fwnode)) {
@@ -101,7 +101,6 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, · 36 unmodified lines
101101 device_for_each_child_node(dev, child) {
102102 if (is_of_node(child)) {
103103 fwnode_property_read_u32(child, "reg", values + i);
104−
105104 } else if (is_acpi_node(child)) {
106105 rc = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), values + i);
107106 if (rc) {
@@ -126,7 +125,7 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) · 18 unmodified lines
126125 struct gpiomux *mux;
127126 struct i2c_adapter *parent;
128127 struct i2c_adapter *root;
129− unsigned initial_state;
128+ unsigned int initial_state;
130129 int i, ngpios, ret;
131130
132131 mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL);
drivers/misc/eeprom/at24.c+12−30
@@ -92,7 +92,7 @@ struct at24_data { · 91 unmodified lines
9292 * them for us.
9393 */
9494 u8 bank_addr_shift;
95− struct regmap *client_regmaps[];
95+ struct regmap *client_regmaps[] __counted_by(num_addresses);
9696 };
9797
9898 /*
@@ -191,9 +191,13 @@ AT24_CHIP_DATA(at24_data_24c16, 16384 / 8, 0); · 92 unmodified lines
191191 AT24_CHIP_DATA(at24_data_24cs16, 16,
192192 AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
193193 AT24_CHIP_DATA(at24_data_24c32, 32768 / 8, AT24_FLAG_ADDR16);
194+/* M24C32-D Additional Write lockable page (M24C32-D order codes) */
195+AT24_CHIP_DATA(at24_data_24c32d_wlp, 32, AT24_FLAG_ADDR16);
194196 AT24_CHIP_DATA(at24_data_24cs32, 16,
195197 AT24_FLAG_ADDR16 | AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
196198 AT24_CHIP_DATA(at24_data_24c64, 65536 / 8, AT24_FLAG_ADDR16);
199+/* M24C64-D Additional Write lockable page (M24C64-D order codes) */
200+AT24_CHIP_DATA(at24_data_24c64d_wlp, 32, AT24_FLAG_ADDR16);
197201 AT24_CHIP_DATA(at24_data_24cs64, 16,
198202 AT24_FLAG_ADDR16 | AT24_FLAG_SERIAL | AT24_FLAG_READONLY);
199203 AT24_CHIP_DATA(at24_data_24c128, 131072 / 8, AT24_FLAG_ADDR16);
@@ -222,8 +226,10 @@ static const struct i2c_device_id at24_ids[] = { · 22 unmodified lines
222226 { "24c16", (kernel_ulong_t)&at24_data_24c16 },
223227 { "24cs16", (kernel_ulong_t)&at24_data_24cs16 },
224228 { "24c32", (kernel_ulong_t)&at24_data_24c32 },
229+ { "24c32d-wl", (kernel_ulong_t)&at24_data_24c32d_wlp },
225230 { "24cs32", (kernel_ulong_t)&at24_data_24cs32 },
226231 { "24c64", (kernel_ulong_t)&at24_data_24c64 },
232+ { "24c64-wl", (kernel_ulong_t)&at24_data_24c64d_wlp },
227233 { "24cs64", (kernel_ulong_t)&at24_data_24cs64 },
228234 { "24c128", (kernel_ulong_t)&at24_data_24c128 },
229235 { "24c256", (kernel_ulong_t)&at24_data_24c256 },
@@ -252,8 +258,10 @@ static const struct of_device_id at24_of_match[] = { · 22 unmodified lines
252258 { .compatible = "atmel,24c16", .data = &at24_data_24c16 },
253259 { .compatible = "atmel,24cs16", .data = &at24_data_24cs16 },
254260 { .compatible = "atmel,24c32", .data = &at24_data_24c32 },
261+ { .compatible = "atmel,24c32d-wl", .data = &at24_data_24c32d_wlp },
255262 { .compatible = "atmel,24cs32", .data = &at24_data_24cs32 },
256263 { .compatible = "atmel,24c64", .data = &at24_data_24c64 },
264+ { .compatible = "atmel,24c64d-wl", .data = &at24_data_24c64d_wlp },
257265 { .compatible = "atmel,24cs64", .data = &at24_data_24cs64 },
258266 { .compatible = "atmel,24c128", .data = &at24_data_24c128 },
259267 { .compatible = "atmel,24c256", .data = &at24_data_24c256 },
@@ -509,32 +517,6 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) · 249 unmodified lines
509517 return 0;
510518 }
511519
512−static const struct at24_chip_data *at24_get_chip_data(struct device *dev)
513−{
514− struct device_node *of_node = dev->of_node;
515− const struct at24_chip_data *cdata;
516− const struct i2c_device_id *id;
517−
518− id = i2c_match_id(at24_ids, to_i2c_client(dev));
519−
520− /*
521− * The I2C core allows OF nodes compatibles to match against the
522− * I2C device ID table as a fallback, so check not only if an OF
523− * node is present but also if it matches an OF device ID entry.
524− */
525− if (of_node && of_match_device(at24_of_match, dev))
526− cdata = of_device_get_match_data(dev);
527− else if (id)
528− cdata = (void *)id->driver_data;
529− else
530− cdata = acpi_device_get_match_data(dev);
531−
532− if (!cdata)
533− return ERR_PTR(-ENODEV);
534−
535− return cdata;
536−}
537−
538520 static int at24_make_dummy_client(struct at24_data *at24, unsigned int index,
539521 struct i2c_client *base_client,
540522 struct regmap_config *regmap_config)
@@ -601,9 +583,9 @@ static int at24_probe(struct i2c_client *client) · 60 unmodified lines
601583 i2c_fn_block = i2c_check_functionality(client->adapter,
602584 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
603585
604− cdata = at24_get_chip_data(dev);
605− if (IS_ERR(cdata))
606− return PTR_ERR(cdata);
586+ cdata = i2c_get_match_data(client);
587+ if (!cdata)
588+ return -ENODEV;
607589
608590 err = device_property_read_u32(dev, "pagesize", &page_size);
609591 if (err)
include/linux/acpi.h+5−0
@@ -1531,4 +1531,9 @@ static inline void acpi_device_notify(struct device *dev) { } · 1530 unmodified lines
15311531 static inline void acpi_device_notify_remove(struct device *dev) { }
15321532 #endif
15331533
1534+static inline void acpi_use_parent_companion(struct device *dev)
1535+{
1536+ ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent));
1537+}
1538+
15341539 #endif /*_LINUX_ACPI_H*/

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t