Skip to content

Commit 1524bb7

Browse files
Jacopo Mondimchehab
authored andcommitted
media: i2c: rdacm20: Embed 'serializer' field
There's no reason to allocate dynamically the 'serializer' field in the driver structure. Embed the field and adjust all its users in the driver. Signed-off-by: Jacopo Mondi <[email protected]> Reviewed-by: Kieran Bingham <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 2b82169 commit 1524bb7

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

drivers/media/i2c/rdacm20.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static const struct ov10635_reg {
312312

313313
struct rdacm20_device {
314314
struct device *dev;
315-
struct max9271_device *serializer;
315+
struct max9271_device serializer;
316316
struct i2c_client *sensor;
317317
struct v4l2_subdev sd;
318318
struct media_pad pad;
@@ -399,7 +399,7 @@ static int rdacm20_s_stream(struct v4l2_subdev *sd, int enable)
399399
{
400400
struct rdacm20_device *dev = sd_to_rdacm20(sd);
401401

402-
return max9271_set_serial_link(dev->serializer, enable);
402+
return max9271_set_serial_link(&dev->serializer, enable);
403403
}
404404

405405
static int rdacm20_enum_mbus_code(struct v4l2_subdev *sd,
@@ -455,46 +455,46 @@ static int rdacm20_initialize(struct rdacm20_device *dev)
455455
unsigned int retry = 3;
456456
int ret;
457457

458-
max9271_wake_up(dev->serializer);
458+
max9271_wake_up(&dev->serializer);
459459

460460
/* Serial link disabled during config as it needs a valid pixel clock. */
461-
ret = max9271_set_serial_link(dev->serializer, false);
461+
ret = max9271_set_serial_link(&dev->serializer, false);
462462
if (ret)
463463
return ret;
464464

465465
/*
466466
* Ensure that we have a good link configuration before attempting to
467467
* identify the device.
468468
*/
469-
max9271_configure_i2c(dev->serializer, MAX9271_I2CSLVSH_469NS_234NS |
470-
MAX9271_I2CSLVTO_1024US |
471-
MAX9271_I2CMSTBT_105KBPS);
469+
max9271_configure_i2c(&dev->serializer, MAX9271_I2CSLVSH_469NS_234NS |
470+
MAX9271_I2CSLVTO_1024US |
471+
MAX9271_I2CMSTBT_105KBPS);
472472

473-
max9271_configure_gmsl_link(dev->serializer);
473+
max9271_configure_gmsl_link(&dev->serializer);
474474

475-
ret = max9271_verify_id(dev->serializer);
475+
ret = max9271_verify_id(&dev->serializer);
476476
if (ret < 0)
477477
return ret;
478478

479-
ret = max9271_set_address(dev->serializer, dev->addrs[0]);
479+
ret = max9271_set_address(&dev->serializer, dev->addrs[0]);
480480
if (ret < 0)
481481
return ret;
482-
dev->serializer->client->addr = dev->addrs[0];
482+
dev->serializer.client->addr = dev->addrs[0];
483483

484484
/*
485485
* Reset the sensor by cycling the OV10635 reset signal connected to the
486486
* MAX9271 GPIO1 and verify communication with the OV10635.
487487
*/
488-
ret = max9271_enable_gpios(dev->serializer, MAX9271_GPIO1OUT);
488+
ret = max9271_enable_gpios(&dev->serializer, MAX9271_GPIO1OUT);
489489
if (ret)
490490
return ret;
491491

492-
ret = max9271_clear_gpios(dev->serializer, MAX9271_GPIO1OUT);
492+
ret = max9271_clear_gpios(&dev->serializer, MAX9271_GPIO1OUT);
493493
if (ret)
494494
return ret;
495495
usleep_range(10000, 15000);
496496

497-
ret = max9271_set_gpios(dev->serializer, MAX9271_GPIO1OUT);
497+
ret = max9271_set_gpios(&dev->serializer, MAX9271_GPIO1OUT);
498498
if (ret)
499499
return ret;
500500
usleep_range(10000, 15000);
@@ -552,13 +552,7 @@ static int rdacm20_probe(struct i2c_client *client)
552552
if (!dev)
553553
return -ENOMEM;
554554
dev->dev = &client->dev;
555-
556-
dev->serializer = devm_kzalloc(&client->dev, sizeof(*dev->serializer),
557-
GFP_KERNEL);
558-
if (!dev->serializer)
559-
return -ENOMEM;
560-
561-
dev->serializer->client = client;
555+
dev->serializer.client = client;
562556

563557
ret = of_property_read_u32_array(client->dev.of_node, "reg",
564558
dev->addrs, 2);

0 commit comments

Comments
 (0)