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

media: i2c: ad5820: simplify getting state container

The pointer to 'struct v4l2_subdev' is stored in drvdata via
v4l2_i2c_subdev_init() so there is no point of a dance like:

struct i2c_client *client = to_i2c_client(struct device *dev)
struct v4l2_subdev *sd = i2c_get_clientdata(client);

This allows to remove local variable 'client' and few pointer
dereferences.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mauro Carvalho Chehab
3d520123 bbaecc36

+2 -4
+2 -4
drivers/media/i2c/ad5820.c
··· 270 270 */ 271 271 static int __maybe_unused ad5820_suspend(struct device *dev) 272 272 { 273 - struct i2c_client *client = container_of(dev, struct i2c_client, dev); 274 - struct v4l2_subdev *subdev = i2c_get_clientdata(client); 273 + struct v4l2_subdev *subdev = dev_get_drvdata(dev); 275 274 struct ad5820_device *coil = to_ad5820_device(subdev); 276 275 277 276 if (!coil->power_count) ··· 281 282 282 283 static int __maybe_unused ad5820_resume(struct device *dev) 283 284 { 284 - struct i2c_client *client = container_of(dev, struct i2c_client, dev); 285 - struct v4l2_subdev *subdev = i2c_get_clientdata(client); 285 + struct v4l2_subdev *subdev = dev_get_drvdata(dev); 286 286 struct ad5820_device *coil = to_ad5820_device(subdev); 287 287 288 288 if (!coil->power_count)