Commit bdfe0beb authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: atomisp: fix several coding style issues



Use checkpatch.pl --fix-inplace --strict to solve several
coding style issues, manually reviewing the produced code and
fixing some troubles caused by checkpatch.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 4636a85c
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@ static int gc0310_write_reg_array(struct i2c_client *client,

	return __gc0310_flush_reg_array(client, &ctrl);
}

static int gc0310_g_focal(struct v4l2_subdev *sd, s32 *val)
{
	*val = (GC0310_FOCAL_LENGTH_NUM << 16) | GC0310_FOCAL_LENGTH_DEM;
@@ -499,6 +500,7 @@ static long gc0310_s_exposure(struct v4l2_subdev *sd,
	/* we should not accept the invalid value below. */
	if (gain == 0) {
		struct i2c_client *client = v4l2_get_subdevdata(sd);

		v4l2_err(client, "%s: invalid value\n", __func__);
		return -EINVAL;
	}
@@ -520,7 +522,6 @@ static int gc0310_h_flip(struct v4l2_subdev *sd, s32 value)

static long gc0310_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{

	switch (cmd) {
	case ATOMISP_IOC_S_EXPOSURE:
		return gc0310_s_exposure(sd, arg);
@@ -734,6 +735,7 @@ static int power_ctrl(struct v4l2_subdev *sd, bool flag)
{
	int ret = 0;
	struct gc0310_device *dev = to_gc0310_sensor(sd);

	if (!dev || !dev->platform_data)
		return -ENODEV;

@@ -783,7 +785,6 @@ static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
	return ret;
}


static int power_down(struct v4l2_subdev *sd);

static int power_up(struct v4l2_subdev *sd)
@@ -867,6 +868,7 @@ static int power_down(struct v4l2_subdev *sd)
static int gc0310_s_power(struct v4l2_subdev *sd, int on)
{
	int ret;

	if (on == 0)
		return power_down(sd);
	else {
@@ -899,9 +901,9 @@ static int distance(struct gc0310_resolution *res, u32 w, u32 h)
	h_ratio = (res->height << 13) / h;
	if (h_ratio == 0)
		return -1;
	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
	match   = abs(((w_ratio << 13) / h_ratio) - 8192);

	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
		return -1;

@@ -947,7 +949,6 @@ static int get_resolution_index(int w, int h)
	return -1;
}


/* TODO: remove it. */
static int startup(struct v4l2_subdev *sd)
{
@@ -977,6 +978,7 @@ static int gc0310_set_fmt(struct v4l2_subdev *sd,
	struct camera_mipi_info *gc0310_info = NULL;
	int ret = 0;
	int idx = 0;

	pr_info("%s S\n", __func__);

	if (format->pad)
@@ -1015,7 +1017,7 @@ static int gc0310_set_fmt(struct v4l2_subdev *sd,
		return -EINVAL;
	}

	printk("%s: before gc0310_write_reg_array %s\n", __FUNCTION__,
	printk("%s: before gc0310_write_reg_array %s\n", __func__,
	       gc0310_res[dev->fmt_idx].desc);
	ret = startup(sd);
	if (ret) {
@@ -1140,7 +1142,6 @@ static int gc0310_s_stream(struct v4l2_subdev *sd, int enable)
	return ret;
}


static int gc0310_s_config(struct v4l2_subdev *sd,
			   int irq, void *platform_data)
{
@@ -1241,10 +1242,8 @@ static int gc0310_enum_frame_size(struct v4l2_subdev *sd,
	fse->max_height = gc0310_res[index].height;

	return 0;

}


static int gc0310_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
{
	struct gc0310_device *dev = to_gc0310_sensor(sd);
@@ -1288,6 +1287,7 @@ static int gc0310_remove(struct i2c_client *client)
{
	struct v4l2_subdev *sd = i2c_get_clientdata(client);
	struct gc0310_device *dev = to_gc0310_sensor(sd);

	dev_dbg(&client->dev, "gc0310_remove...\n");

	dev->platform_data->csi_cfg(sd, 0);
@@ -1315,7 +1315,7 @@ static int gc0310_probe(struct i2c_client *client)
	mutex_init(&dev->input_lock);

	dev->fmt_idx = 0;
	v4l2_i2c_subdev_init(&(dev->sd), client, &gc0310_ops);
	v4l2_i2c_subdev_init(&dev->sd, client, &gc0310_ops);

	pdata = gmin_camera_platform_data(&dev->sd,
					  ATOMISP_INPUT_FORMAT_RAW_8,
+10 −6
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ static int __gc2235_buf_reg_array(struct i2c_client *client,

	return 0;
}

static int __gc2235_write_reg_is_consecutive(struct i2c_client *client,
					     struct gc2235_write_ctrl *ctrl,
					     const struct gc2235_reg *next)
@@ -177,6 +178,7 @@ static int __gc2235_write_reg_is_consecutive(struct i2c_client *client,

	return ctrl->buffer.addr + ctrl->index == next->reg;
}

static int gc2235_write_reg_array(struct i2c_client *client,
				  const struct gc2235_reg *reglist)
{
@@ -238,7 +240,6 @@ static int gc2235_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
	return 0;
}


static int gc2235_get_intg_factor(struct i2c_client *client,
				struct camera_mipi_info *info,
				const struct gc2235_resolution *res)
@@ -355,6 +356,7 @@ static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
	u16 coarse_integration = (u16)coarse_itg;
	int ret = 0;
	u16 expo_coarse_h, expo_coarse_l, gain_val = 0xF0, gain_val2 = 0xF0;

	expo_coarse_h = coarse_integration >> 8;
	expo_coarse_l = coarse_integration & 0xff;

@@ -382,7 +384,6 @@ static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
	return ret;
}


static int gc2235_set_exposure(struct v4l2_subdev *sd, int exposure,
	int gain, int digitgain)
{
@@ -406,12 +407,14 @@ static long gc2235_s_exposure(struct v4l2_subdev *sd,
	/* we should not accept the invalid value below. */
	if (gain == 0) {
		struct i2c_client *client = v4l2_get_subdevdata(sd);

		v4l2_err(client, "%s: invalid value\n", __func__);
		return -EINVAL;
	}

	return gc2235_set_exposure(sd, exp, gain, digitgain);
}

static long gc2235_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
	switch (cmd) {
@@ -422,6 +425,7 @@ static long gc2235_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
	}
	return 0;
}

/* This returns the exposure time being used. This should only be used
 * for filling in EXIF data, not for actual image processing.
 */
@@ -739,6 +743,7 @@ static int startup(struct v4l2_subdev *sd)
	struct gc2235_device *dev = to_gc2235_sensor(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int ret = 0;

	if (is_init == 0) {
		/* force gc2235 to do a reset in res change, otherwise it
		* can not output normal after switching res. and it is not
@@ -764,7 +769,6 @@ static int gc2235_set_fmt(struct v4l2_subdev *sd,
			  struct v4l2_subdev_pad_config *cfg,
			  struct v4l2_subdev_format *format)
{

	struct v4l2_mbus_framefmt *fmt = &format->format;
	struct gc2235_device *dev = to_gc2235_sensor(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -873,6 +877,7 @@ static int gc2235_s_stream(struct v4l2_subdev *sd, int enable)
	struct gc2235_device *dev = to_gc2235_sensor(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int ret;

	mutex_lock(&dev->input_lock);

	if (enable)
@@ -884,7 +889,6 @@ static int gc2235_s_stream(struct v4l2_subdev *sd, int enable)
	return ret;
}


static int gc2235_s_config(struct v4l2_subdev *sd,
			   int irq, void *platform_data)
{
@@ -983,7 +987,6 @@ static int gc2235_enum_frame_size(struct v4l2_subdev *sd,
	fse->max_height = gc2235_res[index].height;

	return 0;

}

static int gc2235_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
@@ -1029,6 +1032,7 @@ static int gc2235_remove(struct i2c_client *client)
{
	struct v4l2_subdev *sd = i2c_get_clientdata(client);
	struct gc2235_device *dev = to_gc2235_sensor(sd);

	dev_dbg(&client->dev, "gc2235_remove...\n");

	dev->platform_data->csi_cfg(sd, 0);
@@ -1055,7 +1059,7 @@ static int gc2235_probe(struct i2c_client *client)
	mutex_init(&dev->input_lock);

	dev->fmt_idx = 0;
	v4l2_i2c_subdev_init(&(dev->sd), client, &gc2235_ops);
	v4l2_i2c_subdev_init(&dev->sd, client, &gc2235_ops);

	gcpdev = gmin_camera_platform_data(&dev->sd,
				   ATOMISP_INPUT_FORMAT_RAW_10,
+18 −16
Original line number Diff line number Diff line
@@ -22,26 +22,26 @@

/* Tagged binary data container structure definitions. */
struct tbd_header {
	uint32_t tag;          /*!< Tag identifier, also checks endianness */
	uint32_t size;         /*!< Container size including this header */
	uint32_t version;      /*!< Version, format 0xYYMMDDVV */
	uint32_t revision;     /*!< Revision, format 0xYYMMDDVV */
	uint32_t config_bits;  /*!< Configuration flag bits set */
	uint32_t checksum;     /*!< Global checksum, header included */
	u32 tag;          /*!< Tag identifier, also checks endianness */
	u32 size;         /*!< Container size including this header */
	u32 version;      /*!< Version, format 0xYYMMDDVV */
	u32 revision;     /*!< Revision, format 0xYYMMDDVV */
	u32 config_bits;  /*!< Configuration flag bits set */
	u32 checksum;     /*!< Global checksum, header included */
} __packed;

struct tbd_record_header {
	uint32_t size;        /*!< Size of record including header */
	uint8_t format_id;    /*!< tbd_format_t enumeration values used */
	uint8_t packing_key;  /*!< Packing method; 0 = no packing */
	uint16_t class_id;    /*!< tbd_class_t enumeration values used */
	u32 size;        /*!< Size of record including header */
	u8 format_id;    /*!< tbd_format_t enumeration values used */
	u8 packing_key;  /*!< Packing method; 0 = no packing */
	u16 class_id;    /*!< tbd_class_t enumeration values used */
} __packed;

struct tbd_data_record_header {
	uint16_t next_offset;
	uint16_t flags;
	uint16_t data_offset;
	uint16_t data_size;
	u16 next_offset;
	u16 flags;
	u16 data_offset;
	u16 data_size;
} __packed;

#define TBD_CLASS_DRV_ID 2
@@ -58,7 +58,8 @@ static int set_msr_configuration(struct i2c_client *client, uint8_t *bufptr,
	 * followed by lobyte) where the remaining data in the sequence
	 * will be written. */

	uint8_t *ptr = bufptr;
	u8 *ptr = bufptr;

	while (ptr < bufptr + size) {
		struct i2c_msg msg = {
			.addr = client->addr,
@@ -88,7 +89,7 @@ static int set_msr_configuration(struct i2c_client *client, uint8_t *bufptr,
static int parse_and_apply(struct i2c_client *client, uint8_t *buffer,
		unsigned int size)
{
	uint8_t *endptr8 = buffer + size;
	u8 *endptr8 = buffer + size;
	struct tbd_data_record_header *header =
		(struct tbd_data_record_header *)buffer;

@@ -170,6 +171,7 @@ int load_msr_list(struct i2c_client *client, char *name,
		const struct firmware **fw)
{
	int ret = request_firmware(fw, name, &client->dev);

	if (ret) {
		dev_err(&client->dev,
			"Error %d while requesting firmware %s\n",
+8 −9
Original line number Diff line number Diff line
@@ -46,14 +46,14 @@
#define LM3554_CURRENT_LIMIT_SHIFT	5

#define LM3554_FLAGS_REG		0xD0
#define LM3554_FLAG_TIMEOUT		(1 << 0)
#define LM3554_FLAG_THERMAL_SHUTDOWN	(1 << 1)
#define LM3554_FLAG_LED_FAULT		(1 << 2)
#define LM3554_FLAG_TX1_INTERRUPT	(1 << 3)
#define LM3554_FLAG_TX2_INTERRUPT	(1 << 4)
#define LM3554_FLAG_LED_THERMAL_FAULT	(1 << 5)
#define LM3554_FLAG_UNUSED		(1 << 6)
#define LM3554_FLAG_INPUT_VOLTAGE_LOW	(1 << 7)
#define LM3554_FLAG_TIMEOUT		BIT(0)
#define LM3554_FLAG_THERMAL_SHUTDOWN	BIT(1)
#define LM3554_FLAG_LED_FAULT		BIT(2)
#define LM3554_FLAG_TX1_INTERRUPT	BIT(3)
#define LM3554_FLAG_TX2_INTERRUPT	BIT(4)
#define LM3554_FLAG_LED_THERMAL_FAULT	BIT(5)
#define LM3554_FLAG_UNUSED		BIT(6)
#define LM3554_FLAG_INPUT_VOLTAGE_LOW	BIT(7)

#define LM3554_CONFIG_REG_1		0xE0
#define LM3554_ENVM_TX2_SHIFT		5
@@ -881,7 +881,6 @@ static int lm3554_probe(struct i2c_client *client)
				     NULL);

	if (flash->ctrl_handler.error) {

		dev_err(&client->dev, "ctrl_handler error.\n");
		goto fail2;
	}
+15 −14
Original line number Diff line number Diff line
@@ -239,7 +239,6 @@ misensor_rmw_reg(struct i2c_client *client, u16 data_length, u16 reg,
	return 0;
}


static int __mt9m114_flush_reg_array(struct i2c_client *client,
				     struct mt9m114_write_ctrl *ctrl)
{
@@ -428,12 +427,12 @@ static int mt9m114_wait_state(struct i2c_client *client, int timeout)
	}

	return -EINVAL;

}

static int mt9m114_set_suspend(struct v4l2_subdev *sd)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);

	return mt9m114_write_reg_array(client,
			mt9m114_standby_reg, POST_POLLING);
}
@@ -499,7 +498,7 @@ static int power_up(struct v4l2_subdev *sd)
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int ret;

	if (NULL == dev->platform_data) {
	if (!dev->platform_data) {
		dev_err(&client->dev, "no camera_sensor_platform_data");
		return -ENODEV;
	}
@@ -541,7 +540,7 @@ static int power_down(struct v4l2_subdev *sd)
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int ret;

	if (NULL == dev->platform_data) {
	if (!dev->platform_data) {
		dev_err(&client->dev, "no camera_sensor_platform_data");
		return -ENODEV;
	}
@@ -704,9 +703,9 @@ static int mt9m114_res2size(struct v4l2_subdev *sd, int *h_size, int *v_size)
		return -EINVAL;
	}

	if (h_size != NULL)
	if (h_size)
		*h_size = hsize;
	if (v_size != NULL)
	if (v_size)
		*v_size = vsize;

	return 0;
@@ -720,7 +719,7 @@ static int mt9m114_get_intg_factor(struct i2c_client *client,
	u32 reg_val;
	int ret;

	if (info == NULL)
	if (!info)
		return -EINVAL;

	ret =  mt9m114_read_reg(client, MISENSOR_32BIT,
@@ -807,6 +806,7 @@ static int mt9m114_get_fmt(struct v4l2_subdev *sd,
	struct v4l2_mbus_framefmt *fmt = &format->format;
	int width, height;
	int ret;

	if (format->pad)
		return -EINVAL;
	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
@@ -833,13 +833,14 @@ static int mt9m114_set_fmt(struct v4l2_subdev *sd,
	struct camera_mipi_info *mt9m114_info = NULL;

	int ret;

	if (format->pad)
		return -EINVAL;
	dev->streamon = 0;
	dev->first_exp = MT9M114_DEFAULT_FIRST_EXP;

	mt9m114_info = v4l2_get_subdev_hostdata(sd);
	if (mt9m114_info == NULL)
	if (!mt9m114_info)
		return -EINVAL;

	mt9m114_try_res(&width, &height);
@@ -964,6 +965,7 @@ static int mt9m114_g_hflip(struct v4l2_subdev *sd, s32 *val)
	struct i2c_client *c = v4l2_get_subdevdata(sd);
	int ret;
	u32 data;

	ret = mt9m114_read_reg(c, MISENSOR_16BIT,
			(u32)MISENSOR_READ_MODE, &data);
	if (ret)
@@ -1082,7 +1084,6 @@ static long mt9m114_s_exposure(struct v4l2_subdev *sd,

static long mt9m114_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{

	switch (cmd) {
	case ATOMISP_IOC_S_EXPOSURE:
		return mt9m114_s_exposure(sd, arg);
@@ -1110,6 +1111,7 @@ static int mt9m114_g_exposure(struct v4l2_subdev *sd, s32 *value)
	*value = coarse;
	return 0;
}

#ifndef CSS15
/*
 * This function will return the sensor supported max exposure zone number.
@@ -1563,7 +1565,7 @@ mt9m114_s_config(struct v4l2_subdev *sd, int irq, void *platform_data)
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int ret;

	if (NULL == platform_data)
	if (!platform_data)
		return -ENODEV;

	dev->platform_data =
@@ -1738,7 +1740,6 @@ static int mt9m114_enum_frame_size(struct v4l2_subdev *sd,
				   struct v4l2_subdev_pad_config *cfg,
				   struct v4l2_subdev_frame_size_enum *fse)
{

	unsigned int index = fse->index;

	if (index >= N_RES)
@@ -1757,7 +1758,7 @@ static int mt9m114_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
	int index;
	struct mt9m114_device *snr = to_mt9m114_sensor(sd);

	if (frames == NULL)
	if (!frames)
		return -EINVAL;

	for (index = 0; index < N_RES; index++) {
Loading