mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 23:25:13 -04:00
Merge tag 'w1-drv-7.3' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1 into char-misc-next
Krzysztof writes: 1-Wire bus drivers for v7.3 1. Improve (fix) ds2482 driver module autoloading, when probing from Devicetree. 2. Convert HDQ One Wire devicetree bindings to DT schema format. 3. Fixes for handling incorrect data from potentially malicious hardware, looking theoretical issues but still worth to fix. Affected drivers: w1 core code, ds28e17 and ds2482. * tag 'w1-drv-7.3' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1: w1: ds2482: Fix signedness bug in ds2482_w1_triplet() w1: validate slave string length before checking separator w1: ds28e17: reject an oversize length on an I2C block read dt-bindings: w1: Convert HDQ One Wire to DT schema w1: ds2482: add OF device match table
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
* OMAP HDQ One wire bus master controller
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "ti,omap3-1w" or "ti,am4372-hdq"
|
||||
- reg : Address and length of the register set for the device
|
||||
- interrupts : interrupt line.
|
||||
- ti,hwmods : "hdq1w"
|
||||
|
||||
Optional properties:
|
||||
- ti,mode: should be "hdq": HDQ mode "1w": one-wire mode.
|
||||
If not specified HDQ mode is implied.
|
||||
|
||||
Example:
|
||||
|
||||
- From omap3.dtsi
|
||||
hdqw1w: 1w@480b2000 {
|
||||
compatible = "ti,omap3-1w";
|
||||
reg = <0x480b2000 0x1000>;
|
||||
interrupts = <58>;
|
||||
ti,hwmods = "hdq1w";
|
||||
ti,mode = "hdq";
|
||||
};
|
||||
70
Documentation/devicetree/bindings/w1/ti,hdq.yaml
Normal file
70
Documentation/devicetree/bindings/w1/ti,hdq.yaml
Normal file
@@ -0,0 +1,70 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/w1/ti,hdq.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Texas Instruments OMAP HDQ One Wire Bus Master Controller
|
||||
|
||||
maintainers:
|
||||
- Eduard Bostina <egbostina@gmail.com>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- ti,omap3-1w
|
||||
- ti,am4372-hdq
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
maxItems: 1
|
||||
|
||||
clock-names:
|
||||
items:
|
||||
- const: fck
|
||||
|
||||
ti,hwmods:
|
||||
description: Name of the hwmod associated to the hdq
|
||||
$ref: /schemas/types.yaml#/definitions/string
|
||||
const: hdq1w
|
||||
|
||||
ti,mode:
|
||||
description: |
|
||||
Operation mode. "hdq" for HDQ mode, "1w" for One-Wire mode.
|
||||
If not specified, HDQ mode is implied.
|
||||
$ref: /schemas/types.yaml#/definitions/string
|
||||
enum:
|
||||
- hdq
|
||||
- 1w
|
||||
default: hdq
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- interrupts
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
onewire@0 {
|
||||
compatible = "ti,am4372-hdq";
|
||||
reg = <0x0 0x1000>;
|
||||
interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clocks = <&func_12m_clk>;
|
||||
clock-names = "fck";
|
||||
};
|
||||
- |
|
||||
onewire@480b2000 {
|
||||
compatible = "ti,omap3-1w";
|
||||
reg = <0x480b2000 0x1000>;
|
||||
interrupts = <58>;
|
||||
ti,hwmods = "hdq1w";
|
||||
ti,mode = "hdq";
|
||||
};
|
||||
@@ -50,5 +50,5 @@ The driver also supports 1-wire mode. In this mode, there is no need to
|
||||
pass slave ID as parameter. The driver will auto-detect slaves connected
|
||||
to the bus using SEARCH_ROM procedure. 1-wire mode can be selected by
|
||||
setting "ti,mode" property to "1w" in DT (see
|
||||
Documentation/devicetree/bindings/w1/omap-hdq.txt for more details).
|
||||
Documentation/devicetree/bindings/w1/ti,hdq.yaml for more details).
|
||||
By default driver is in HDQ mode.
|
||||
|
||||
@@ -310,6 +310,10 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit)
|
||||
|
||||
mutex_unlock(&pdev->access_lock);
|
||||
|
||||
/* On bus error, decode to 3 (no device responded) to abort the search */
|
||||
if (status < 0)
|
||||
status = 3 << 5;
|
||||
|
||||
/* Decode the status */
|
||||
return (status >> 5);
|
||||
}
|
||||
@@ -545,9 +549,17 @@ static const struct i2c_device_id ds2482_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ds2482_id);
|
||||
|
||||
static const struct of_device_id ds2482_of_match[] = {
|
||||
{ .compatible = "maxim,ds2482", },
|
||||
{ .compatible = "maxim,ds2484", },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ds2482_of_match);
|
||||
|
||||
static struct i2c_driver ds2482_driver = {
|
||||
.driver = {
|
||||
.name = "ds2482",
|
||||
.of_match_table = ds2482_of_match,
|
||||
},
|
||||
.probe = ds2482_probe,
|
||||
.remove = ds2482_remove,
|
||||
|
||||
@@ -389,6 +389,10 @@ static int w1_f19_i2c_master_transfer(struct i2c_adapter *adapter,
|
||||
* another simple read in that case.
|
||||
*/
|
||||
if (msgs[i+1].flags & I2C_M_RECV_LEN) {
|
||||
if (msgs[i+1].buf[0] > I2C_SMBUS_BLOCK_MAX) {
|
||||
i = -EPROTO;
|
||||
goto error;
|
||||
}
|
||||
result = w1_f19_i2c_read(sl, msgs[i+1].addr,
|
||||
&(msgs[i+1].buf[1]), msgs[i+1].buf[0]);
|
||||
if (result < 0) {
|
||||
@@ -415,6 +419,10 @@ static int w1_f19_i2c_master_transfer(struct i2c_adapter *adapter,
|
||||
* another simple read in that case.
|
||||
*/
|
||||
if (msgs[i].flags & I2C_M_RECV_LEN) {
|
||||
if (msgs[i].buf[0] > I2C_SMBUS_BLOCK_MAX) {
|
||||
i = -EPROTO;
|
||||
goto error;
|
||||
}
|
||||
result = w1_f19_i2c_read(sl,
|
||||
msgs[i].addr,
|
||||
&(msgs[i].buf[1]),
|
||||
|
||||
@@ -403,6 +403,11 @@ static int w1_atoreg_num(struct device *dev, const char *buf, size_t count,
|
||||
const char *error_msg = "bad slave string format, expecting "
|
||||
"ff-dddddddddddd\n";
|
||||
|
||||
if (count < 3) {
|
||||
dev_err(dev, "%s", error_msg);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (buf[2] != '-') {
|
||||
dev_err(dev, "%s", error_msg);
|
||||
return -EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user