Skip to content

Commit be40a3a

Browse files
Andi Shytiwsakernel
authored andcommitted
i2c: mpc: Use of_property_read_u32 instead of of_get_property
"of_property_read_u32()" is preferred to "of_get_property()" for retrieving u32 from the device tree. Replace it. Suggested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent ba085a8 commit be40a3a

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

drivers/i2c/busses/i2c-mpc.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ static const struct i2c_algorithm mpc_algo = {
770770
static struct i2c_adapter mpc_ops = {
771771
.owner = THIS_MODULE,
772772
.algo = &mpc_algo,
773-
.timeout = HZ,
774773
};
775774

776775
static struct i2c_bus_recovery_info fsl_i2c_recovery_info = {
@@ -781,11 +780,9 @@ static int fsl_i2c_probe(struct platform_device *op)
781780
{
782781
const struct mpc_i2c_data *data;
783782
struct mpc_i2c *i2c;
784-
const u32 *prop;
785-
u32 clock = MPC_I2C_CLOCK_LEGACY;
786-
int result = 0;
787-
int plen;
788783
struct clk *clk;
784+
int result;
785+
u32 clock;
789786
int err;
790787

791788
i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL);
@@ -831,10 +828,10 @@ static int fsl_i2c_probe(struct platform_device *op)
831828
if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) {
832829
clock = MPC_I2C_CLOCK_PRESERVE;
833830
} else {
834-
prop = of_get_property(op->dev.of_node, "clock-frequency",
835-
&plen);
836-
if (prop && plen == sizeof(u32))
837-
clock = *prop;
831+
result = of_property_read_u32(op->dev.of_node,
832+
"clock-frequency", &clock);
833+
if (result)
834+
clock = MPC_I2C_CLOCK_LEGACY;
838835
}
839836

840837
data = device_get_match_data(&op->dev);
@@ -846,12 +843,16 @@ static int fsl_i2c_probe(struct platform_device *op)
846843
mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock);
847844
}
848845

849-
prop = of_get_property(op->dev.of_node, "fsl,timeout", &plen);
850-
if (prop && plen == sizeof(u32)) {
851-
mpc_ops.timeout = *prop * HZ / 1000000;
846+
result = of_property_read_u32(op->dev.of_node,
847+
"fsl,timeout", &mpc_ops.timeout);
848+
if (!result) {
849+
mpc_ops.timeout *= HZ / 1000000;
852850
if (mpc_ops.timeout < 5)
853851
mpc_ops.timeout = 5;
852+
} else {
853+
mpc_ops.timeout = HZ;
854854
}
855+
855856
dev_info(i2c->dev, "timeout %u us\n", mpc_ops.timeout * 1000000 / HZ);
856857

857858
if (of_property_read_bool(op->dev.of_node, "fsl,i2c-erratum-a004447"))

0 commit comments

Comments
 (0)