Patch Detail
Show a patch.
GET /api/patches/4151/?format=api
{ "id": 4151, "url": "https://patchwork.libcamera.org/api/patches/4151/?format=api", "web_url": "https://patchwork.libcamera.org/patch/4151/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200623100815.10674-8-jacopo@jmondi.org>", "date": "2020-06-23T10:07:57", "name": "[libcamera-devel,07/25] media: ov5647: Fix style issues", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "ee7f89c571c7b8d71e052f3946bc8418737aea39", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/4151/mbox/", "series": [ { "id": 1030, "url": "https://patchwork.libcamera.org/api/series/1030/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1030", "date": "2020-06-23T10:07:50", "name": "media: ov5647: Support RaspberryPi Camera Module v1", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1030/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/4151/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/4151/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E9C8609A3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 12:05:32 +0200 (CEST)", "from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 4E675C0003;\n\tTue, 23 Jun 2020 10:05:29 +0000 (UTC)" ], "X-Originating-IP": "93.34.118.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "mchehab@kernel.org, sakari.ailus@linux.intel.com, hverkuil@xs4all.nl,\n\tlaurent.pinchart@ideasonboard.com, roman.kovalivskyi@globallogic.com, \n\tdave.stevenson@raspberrypi.org, naush@raspberrypi.com", "Cc": "Jacopo Mondi <jacopo@jmondi.org>, mrodin@de.adit-jv.com,\n\thugues.fruchet@st.com, mripard@kernel.org, aford173@gmail.com,\n\tsudipi@jp.adit-jv.com, andrew_gabbasov@mentor.com,\n\terosca@de.adit-jv.com, \n\tlinux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org", "Date": "Tue, 23 Jun 2020 12:07:57 +0200", "Message-Id": "<20200623100815.10674-8-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200623100815.10674-1-jacopo@jmondi.org>", "References": "<20200623100815.10674-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 07/25] media: ov5647: Fix style issues", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Tue, 23 Jun 2020 10:05:32 -0000" }, "content": "The driver has some obvious style issues which are worth fixing before\nexpanding the driver capabilities.\n\nFix:\n- Variable declaration order\n- Function parameters alignment\n- Multi-line comments and spurious line breaks\n- Use lowercase for hexadecimal values\n\nCosmetic change, no functional changes intended.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n drivers/media/i2c/ov5647.c | 101 +++++++++++++++++--------------------\n 1 file changed, 45 insertions(+), 56 deletions(-)", "diff": "diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c\nindex c92856d3aa81c..e9679382623f9 100644\n--- a/drivers/media/i2c/ov5647.c\n+++ b/drivers/media/i2c/ov5647.c\n@@ -34,8 +34,6 @@\n #include <media/v4l2-image-sizes.h>\n #include <media/v4l2-mediabus.h>\n \n-#define SENSOR_NAME \"ov5647\"\n-\n /*\n * From the datasheet, \"20ms after PWDN goes low or 20ms after RESETB goes\n * high if reset is inserted after PWDN goes high, host can access sensor's\n@@ -50,9 +48,9 @@\n \n #define OV5647_SW_STANDBY\t\t0x0100\n #define OV5647_SW_RESET\t\t\t0x0103\n-#define OV5647_REG_CHIPID_H\t\t0x300A\n-#define OV5647_REG_CHIPID_L\t\t0x300B\n-#define OV5640_REG_PAD_OUT\t\t0x300D\n+#define OV5647_REG_CHIPID_H\t\t0x300a\n+#define OV5647_REG_CHIPID_L\t\t0x300b\n+#define OV5640_REG_PAD_OUT\t\t0x300d\n #define OV5647_REG_FRAME_OFF_NUMBER\t0x4202\n #define OV5647_REG_MIPI_CTRL00\t\t0x4800\n #define OV5647_REG_MIPI_CTRL14\t\t0x4814\n@@ -158,7 +156,7 @@ static struct regval_list ov5647_640x480[] = {\n \t{0x3808, 0x02},\n \t{0x3809, 0x80},\n \t{0x380a, 0x01},\n-\t{0x380b, 0xE0},\n+\t{0x380b, 0xe0},\n \t{0x3801, 0x00},\n \t{0x3802, 0x00},\n \t{0x3803, 0x00},\n@@ -209,9 +207,9 @@ static struct regval_list ov5647_640x480[] = {\n \n static int ov5647_write(struct v4l2_subdev *sd, u16 reg, u8 val)\n {\n-\tint ret;\n \tunsigned char data[3] = { reg >> 8, reg & 0xff, val};\n \tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n+\tint ret;\n \n \tret = i2c_master_send(client, data, 3);\n \tif (ret < 0)\n@@ -223,9 +221,9 @@ static int ov5647_write(struct v4l2_subdev *sd, u16 reg, u8 val)\n \n static int ov5647_read(struct v4l2_subdev *sd, u16 reg, u8 *val)\n {\n-\tint ret;\n \tunsigned char data_w[2] = { reg >> 8, reg & 0xff };\n \tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n+\tint ret;\n \n \tret = i2c_master_send(client, data_w, 2);\n \tif (ret < 0) {\n@@ -243,7 +241,7 @@ static int ov5647_read(struct v4l2_subdev *sd, u16 reg, u8 *val)\n }\n \n static int ov5647_write_array(struct v4l2_subdev *sd,\n-\t\t\t\tstruct regval_list *regs, int array_size)\n+\t\t\t struct regval_list *regs, int array_size)\n {\n \tint i, ret;\n \n@@ -266,6 +264,7 @@ static int ov5647_set_virtual_channel(struct v4l2_subdev *sd, int channel)\n \t\treturn ret;\n \n \tchannel_id &= ~(3 << 6);\n+\n \treturn ov5647_write(sd, OV5647_REG_MIPI_CTRL14, channel_id | (channel << 6));\n }\n \n@@ -294,8 +293,8 @@ static int ov5647_stream_off(struct v4l2_subdev *sd)\n {\n \tint ret;\n \n-\tret = ov5647_write(sd, OV5647_REG_MIPI_CTRL00, MIPI_CTRL00_CLOCK_LANE_GATE\n-\t\t\t | MIPI_CTRL00_BUS_IDLE | MIPI_CTRL00_CLOCK_LANE_DISABLE);\n+\tret = ov5647_write(sd, OV5647_REG_MIPI_CTRL00, MIPI_CTRL00_CLOCK_LANE_GATE |\n+\t\t\t MIPI_CTRL00_BUS_IDLE | MIPI_CTRL00_CLOCK_LANE_DISABLE);\n \tif (ret < 0)\n \t\treturn ret;\n \n@@ -325,16 +324,16 @@ static int set_sw_standby(struct v4l2_subdev *sd, bool standby)\n \n static int __sensor_init(struct v4l2_subdev *sd)\n {\n-\tint ret;\n-\tu8 resetval, rdval;\n \tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n+\tu8 resetval, rdval;\n+\tint ret;\n \n \tret = ov5647_read(sd, OV5647_SW_STANDBY, &rdval);\n \tif (ret < 0)\n \t\treturn ret;\n \n \tret = ov5647_write_array(sd, ov5647_640x480,\n-\t\t\t\t\tARRAY_SIZE(ov5647_640x480));\n+\t\t\t\t ARRAY_SIZE(ov5647_640x480));\n \tif (ret < 0) {\n \t\tdev_err(&client->dev, \"write sensor default regs error\\n\");\n \t\treturn ret;\n@@ -355,17 +354,15 @@ static int __sensor_init(struct v4l2_subdev *sd)\n \t\t\treturn ret;\n \t}\n \n-\t/*\n-\t * stream off to make the clock lane into LP-11 state.\n-\t */\n+\t/* Stream off to make the clock lane into LP-11 state. */\n \treturn ov5647_stream_off(sd);\n }\n \n static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)\n {\n-\tint ret = 0;\n-\tstruct ov5647 *ov5647 = to_state(sd);\n \tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n+\tstruct ov5647 *ov5647 = to_state(sd);\n+\tint ret = 0;\n \n \tmutex_lock(&ov5647->lock);\n \n@@ -384,7 +381,7 @@ static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)\n \t\t}\n \n \t\tret = ov5647_write_array(sd, sensor_oe_enable_regs,\n-\t\t\t\tARRAY_SIZE(sensor_oe_enable_regs));\n+\t\t\t\t\t ARRAY_SIZE(sensor_oe_enable_regs));\n \t\tif (ret < 0) {\n \t\t\tclk_disable_unprepare(ov5647->xclk);\n \t\t\tdev_err(&client->dev,\n@@ -403,18 +400,15 @@ static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)\n \t\tdev_dbg(&client->dev, \"OV5647 power off\\n\");\n \n \t\tret = ov5647_write_array(sd, sensor_oe_disable_regs,\n-\t\t\t\tARRAY_SIZE(sensor_oe_disable_regs));\n-\n+\t\t\t\t\t ARRAY_SIZE(sensor_oe_disable_regs));\n \t\tif (ret < 0)\n \t\t\tdev_dbg(&client->dev, \"disable oe failed\\n\");\n \n \t\tret = set_sw_standby(sd, true);\n-\n \t\tif (ret < 0)\n \t\t\tdev_dbg(&client->dev, \"soft stby failed\\n\");\n \n \t\tclk_disable_unprepare(ov5647->xclk);\n-\n \t\tgpiod_set_value_cansleep(ov5647->pwdn, 1);\n \t}\n \n@@ -430,10 +424,10 @@ static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)\n \n #ifdef CONFIG_VIDEO_ADV_DEBUG\n static int ov5647_sensor_get_register(struct v4l2_subdev *sd,\n-\t\t\t\tstruct v4l2_dbg_register *reg)\n+\t\t\t\t struct v4l2_dbg_register *reg)\n {\n-\tu8 val;\n \tint ret;\n+\tu8 val;\n \n \tret = ov5647_read(sd, reg->reg & 0xff, &val);\n \tif (ret < 0)\n@@ -446,15 +440,13 @@ static int ov5647_sensor_get_register(struct v4l2_subdev *sd,\n }\n \n static int ov5647_sensor_set_register(struct v4l2_subdev *sd,\n-\t\t\t\tconst struct v4l2_dbg_register *reg)\n+\t\t\t\t const struct v4l2_dbg_register *reg)\n {\n \treturn ov5647_write(sd, reg->reg & 0xff, reg->val & 0xff);\n }\n #endif\n \n-/*\n- * Subdev core operations registration\n- */\n+/* Subdev core operations registration */\n static const struct v4l2_subdev_core_ops ov5647_subdev_core_ops = {\n \t.s_power\t\t= ov5647_sensor_power,\n #ifdef CONFIG_VIDEO_ADV_DEBUG\n@@ -476,8 +468,8 @@ static const struct v4l2_subdev_video_ops ov5647_subdev_video_ops = {\n };\n \n static int ov5647_enum_mbus_code(struct v4l2_subdev *sd,\n-\t\t\t\tstruct v4l2_subdev_pad_config *cfg,\n-\t\t\t\tstruct v4l2_subdev_mbus_code_enum *code)\n+\t\t\t\t struct v4l2_subdev_pad_config *cfg,\n+\t\t\t\t struct v4l2_subdev_mbus_code_enum *code)\n {\n \tif (code->index > 0)\n \t\treturn -EINVAL;\n@@ -493,7 +485,7 @@ static int ov5647_set_get_fmt(struct v4l2_subdev *sd,\n {\n \tstruct v4l2_mbus_framefmt *fmt = &format->format;\n \n-\t/* Only one format is supported, so return that */\n+\t/* Only one format is supported, so return that. */\n \tmemset(fmt, 0, sizeof(*fmt));\n \tfmt->code = MEDIA_BUS_FMT_SBGGR8_1X8;\n \tfmt->colorspace = V4L2_COLORSPACE_SRGB;\n@@ -518,9 +510,9 @@ static const struct v4l2_subdev_ops ov5647_subdev_ops = {\n \n static int ov5647_detect(struct v4l2_subdev *sd)\n {\n+\tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n \tu8 read;\n \tint ret;\n-\tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n \n \tret = ov5647_write(sd, OV5647_SW_RESET, 0x01);\n \tif (ret < 0)\n@@ -549,10 +541,8 @@ static int ov5647_detect(struct v4l2_subdev *sd)\n \n static int ov5647_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)\n {\n-\tstruct v4l2_mbus_framefmt *format =\n-\t\t\t\tv4l2_subdev_get_try_format(sd, fh->pad, 0);\n-\tstruct v4l2_rect *crop =\n-\t\t\t\tv4l2_subdev_get_try_crop(sd, fh->pad, 0);\n+\tstruct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(sd, fh->pad, 0);\n+\tstruct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, fh->pad, 0);\n \n \tcrop->left = OV5647_COLUMN_START_DEF;\n \tcrop->top = OV5647_ROW_START_DEF;\n@@ -578,7 +568,6 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np)\n \t\t.bus_type = V4L2_MBUS_CSI2_DPHY,\n \t};\n \tstruct device_node *ep;\n-\n \tint ret;\n \n \tep = of_graph_get_next_endpoint(np, NULL);\n@@ -594,17 +583,18 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np)\n \n out:\n \tof_node_put(ep);\n+\n \treturn ret;\n }\n \n static int ov5647_probe(struct i2c_client *client)\n {\n+\tstruct device_node *np = client->dev.of_node;\n \tstruct device *dev = &client->dev;\n \tstruct ov5647 *sensor;\n-\tint ret;\n \tstruct v4l2_subdev *sd;\n-\tstruct device_node *np = client->dev.of_node;\n \tu32 xclk_freq;\n+\tint ret;\n \n \tsensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);\n \tif (!sensor)\n@@ -618,7 +608,6 @@ static int ov5647_probe(struct i2c_client *client)\n \t\t}\n \t}\n \n-\t/* get system clock (xclk) */\n \tsensor->xclk = devm_clk_get(dev, NULL);\n \tif (IS_ERR(sensor->xclk)) {\n \t\tdev_err(dev, \"could not get xclk\");\n@@ -631,22 +620,21 @@ static int ov5647_probe(struct i2c_client *client)\n \t\treturn -EINVAL;\n \t}\n \n-\t/* Request the power down GPIO asserted */\n-\tsensor->pwdn = devm_gpiod_get_optional(&client->dev, \"pwdn\",\n-\t\t\t\t\t GPIOD_OUT_HIGH);\n+\t/* Request the power down GPIO asserted. */\n+\tsensor->pwdn = devm_gpiod_get_optional(dev, \"pwdn\", GPIOD_OUT_HIGH);\n \n \tmutex_init(&sensor->lock);\n \n \tsd = &sensor->sd;\n \tv4l2_i2c_subdev_init(sd, client, &ov5647_subdev_ops);\n-\tsensor->sd.internal_ops = &ov5647_subdev_internal_ops;\n-\tsensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;\n+\tsd->internal_ops = &ov5647_subdev_internal_ops;\n+\tsd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;\n \n \tsensor->pad.flags = MEDIA_PAD_FL_SOURCE;\n \tsd->entity.function = MEDIA_ENT_F_CAM_SENSOR;\n \tret = media_entity_pads_init(&sd->entity, 1, &sensor->pad);\n \tif (ret < 0)\n-\t\tgoto mutex_remove;\n+\t\tgoto mutex_destroy;\n \n \tif (sensor->pwdn) {\n \t\tgpiod_set_value_cansleep(sensor->pwdn, 0);\n@@ -654,22 +642,23 @@ static int ov5647_probe(struct i2c_client *client)\n \t}\n \n \tret = ov5647_detect(sd);\n-\n \tgpiod_set_value_cansleep(sensor->pwdn, 1);\n-\n \tif (ret < 0)\n-\t\tgoto error;\n+\t\tgoto entity_cleanup;\n \n \tret = v4l2_async_register_subdev(sd);\n \tif (ret < 0)\n-\t\tgoto error;\n+\t\tgoto entity_cleanup;\n \n \tdev_dbg(dev, \"OmniVision OV5647 camera driver probed\\n\");\n+\n \treturn 0;\n-error:\n+\n+entity_cleanup:\n \tmedia_entity_cleanup(&sd->entity);\n-mutex_remove:\n+mutex_destroy:\n \tmutex_destroy(&sensor->lock);\n+\n \treturn ret;\n }\n \n@@ -688,7 +677,7 @@ static int ov5647_remove(struct i2c_client *client)\n \n static const struct i2c_device_id ov5647_id[] = {\n \t{ \"ov5647\", 0 },\n-\t{ }\n+\t{ /* sentinel */ }\n };\n MODULE_DEVICE_TABLE(i2c, ov5647_id);\n \n@@ -703,7 +692,7 @@ MODULE_DEVICE_TABLE(of, ov5647_of_match);\n static struct i2c_driver ov5647_driver = {\n \t.driver = {\n \t\t.of_match_table = of_match_ptr(ov5647_of_match),\n-\t\t.name\t= SENSOR_NAME,\n+\t\t.name\t= \"ov5647\",\n \t},\n \t.probe_new\t= ov5647_probe,\n \t.remove\t\t= ov5647_remove,\n", "prefixes": [ "libcamera-devel", "07/25" ] }