On Semi AR0521 sensor driver
Subsystems (4)
Krzysztof Hałasa
maintainerv6 cover On Semi AR0521 sensor driver
Rob, Mauro, media subsystem reviewers,
This is the 6th version of my On Semi AR0521 sensor driver.
The documentation patch (1/2) hasn't been changed from v4:
onnn,ar0521.yaml | 112 1 file changed, 112 insertions(+)
The actual driver (2/2) changes:
MAINTAINERS | 7 drivers/media/i2c/Kconfig | 13 drivers/media/i2c/Makefile | 1 drivers/media/i2c/ar0521.c | 1051 4 files changed, 1072 insertions(+)
- I reformatted the code to fit in 80 columns. Nobody should be asked to make his code worse (and the 80-column version IS worse), and multiple high-profile Linux developers (including the top one) appear to share my opinion, but nevertheless - if it's something that will make it go in, I won't care.
- Basically the same applies to the // comments.
- I have removed the "interval" support (frames per second). Unfortunately this cripples the driver further a bit - the userspace will not be able to set precise frame timings needed for broadcast quality video. I will have to keep a private patch for that. Another effect of this change is that the pixel clock is now fixed at 184 MHz, which by default produces ca. 30 FPS at 2560x1920. This may be problematic on systems with less than 4 MIPI lanes, and/or on ones which can't support higher frequency MIPI bus (the previous version used a calculated clock). Perhaps it will be possible to fix this issue in the future, with a couple of core V4L2 changes.
- the driver now provides the .pre_streamon() for setting LP-11 state on MIPI data and clock lanes. This is compatible with i.MX6 receiver.
- s_power() converted to SET_RUNTIME_PM_OPS().
- the "initial" I2C registers have been all converted to a table of multi-register files, to minimize time spent on I2C bus.
- a lot of smaller changes suggested by Laurent, Sakari, Jacopo and possibly others.
Signature · 5 lines
Krzysztof "Chris" Hałasa Sieć Badawcza Łukasiewicz Przemysłowy Instytut Automatyki i Pomiarów PIAP Al. Jerozolimskie 202, 02-486 Warszawa
Krzysztof Hałasa
maintainerPATCH v6 1/2 dt-binding: media: document ON Semi AR0521 sensor bindings
This file documents DT bindings for the AR0521 camera sensor driver.
Documentation/devicetree/bindings/media/i2c/onnn,ar0521.yaml new file +112 -0
@@ -0,0 +1,112 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/onnn,ar0521.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ON Semiconductor AR0521 MIPI CSI-2 sensor + +maintainers: + - Krzysztof Hałasa <[email protected]> + +description: |- + The AR0521 is a raw CMOS image sensor with MIPI CSI-2 and + I2C-compatible control interface. + +properties: + compatible: + const: onnn,ar0521 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: extclk + + vaa-supply: + description: + Definition of the regulator used as analog (2.7 V) voltage supply. + + vdd-supply: + description: + Definition of the regulator used as digital core (1.2 V) voltage supply. + + vdd_io-supply: + description: + Definition of the regulator used as digital I/O (1.8 V) voltage supply. + + reset-gpios: + description: reset GPIO, usually active low + maxItems: 1 + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: | + Video output port. + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + bus-type: + const: 4 + data-lanes: + anyOf: + - items: + - const: 1 + - items: + - const: 1 + - const: 2 + - items: + - const: 1 + - const: 2 + - const: 3 + - const: 4 + +required: + - compatible + - reg + - clocks + - clock-names + - vaa-supply + - vdd-supply + - vdd_io-supply + - port + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/clock/imx6qdl-clock.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + ar0521: camera-sensor@36 { + compatible = "onnn,ar0521"; + reg = <0x36>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_mipi_camera>; + clocks = <&clks IMX6QDL_CLK_CKO>; + clock-names = "extclk"; + reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; + vaa-supply = <®_2p7v>; + vdd-supply = <®_1p2v>; + vdd_io-supply = <®_1p8v>; + + port { + mipi_camera_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + data-lanes = <1 2 3 4>; + }; + }; + }; + };
Krzysztof Hałasa
maintainerPATCH v6 2/2 Driver for ON Semi AR0521 camera sensor
In reply to Krzysztof HałasaThe driver has been extensively tested in an i.MX6-based system. AR0521 is a 5.7 mm x 4.3 mm, 5 MPix RGGB MIPI/HiSPi BSI CMOS sensor from On Semiconductor.
MAINTAINERS +7 -0
@@ -1383,6 +1383,13 @@ S: Supported W: http://www.aquantia.com F: drivers/net/ethernet/aquantia/atlantic/aq_ptp* +AR0521 ON SEMICONDUCTOR CAMERA SENSOR DRIVER +M: Krzysztof Hałasa <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/media/i2c/onnn,ar0521.yaml +F: drivers/media/i2c/ar0521.c + ARASAN NAND CONTROLLER DRIVER M: Miquel Raynal <[email protected]> M: Naga Sureshkumar Relli <[email protected]>
drivers/media/i2c/Kconfig +13 -0
@@ -733,6 +733,19 @@ config VIDEO_APTINA_PLL config VIDEO_CCS_PLL tristate +config VIDEO_AR0521 + tristate "ON Semiconductor AR0521 sensor support" + depends on I2C && VIDEO_V4L2 + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the ON Semiconductor + AR0521 camera. + + To compile this driver as a module, choose M here: the + module will be called ar0521. + config VIDEO_HI556 tristate "Hynix Hi-556 sensor support" depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
@@ -118,6 +118,7 @@ obj-$(CONFIG_VIDEO_I2C) += video-i2c.o obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o obj-$(CONFIG_VIDEO_OV2659) += ov2659.o obj-$(CONFIG_VIDEO_TC358743) += tc358743.o +obj-$(CONFIG_VIDEO_AR0521) += ar0521.o obj-$(CONFIG_VIDEO_HI556) += hi556.o obj-$(CONFIG_VIDEO_HI846) += hi846.o obj-$(CONFIG_VIDEO_IMX208) += imx208.o
drivers/media/i2c/ar0521.c new file +1051 -0
1,051 lines not on this page · raw message
Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
Quoted 3 lines · Krzysztof Hałasa
The driver has been extensively tested in an i.MX6-based system. AR0521 is a 5.7 mm x 4.3 mm, 5 MPix RGGB MIPI/HiSPi BSI CMOS sensor from On Semiconductor.
trivial notes:
drivers/media/i2c/ar0521.c
Quoted 1 line
drivers/media/i2c/ar0521.c +0
-0
[]
drivers/media/i2c/ar0521.c line 17
Quoted 2 lines
drivers/media/i2c/ar0521.c +2
-0+/* External clock (extclk) frequencies */ +#define AR0521_EXTCLK_MIN (10 * 1000 * 1000)
Generally, adding a prefix like AR0521_ to defines that are locally defined in a single file unnecessarily increases identifier length.
It makes using short line lengths difficult.
e.g. Using this identifier anywhere
Quoted 1 line
+#define
AR0521_REG_HISPI_CONTROL_STATUS_FRAMER_TEST_MODE_ENABLE0x80
Many of the 80 column line lengths and line wrapping used in this file are not really nice to read. I believe you don't have to be strict about 80 column lines.
Quoted 1 line
+#define be
cpu_to_be16
It's a pity there's no way to declare an array with all members having a specific endianness. Making sure all elements in these arrays are declared with be() is tedious.
Quoted 1 line
+#define
AR0521_NUM_SUPPLIESARRAY_SIZE(ar0521_supply_names)
It's almost always better to use ARRAY_SIZE directly and not use a #define for the array size.
drivers/media/i2c/ar0521.c
Quoted 2 lines
drivers/media/i2c/ar0521.c +2
-0+static int ar0521_set_gains (struct ar0521_dev *sensor) +{
[]
drivers/media/i2c/ar0521.c
Quoted 1 line
drivers/media/i2c/ar0521.c +1
-0+dev_dbg (&sensor->i2c_client->dev,"%s()\n" , __func__);
ftrace works and perhaps all the similar debug logging uses aren't really necessary.
Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
Hi Joe,
sorry to jump in
Quoted 18 lines · Joe Perches
Quoted 3 lines · Krzysztof Hałasa
The driver has been extensively tested in an i.MX6-based system. AR0521 is a 5.7 mm x 4.3 mm, 5 MPix RGGB MIPI/HiSPi BSI CMOS sensor from On Semiconductor.
trivial notes:
drivers/media/i2c/ar0521.c
Quoted 1 line
drivers/media/i2c/ar0521.c +0
-0[]
drivers/media/i2c/ar0521.c line 17
Quoted 2 lines
drivers/media/i2c/ar0521.c +2
-0+/* External clock (extclk) frequencies */ +#define AR0521_EXTCLK_MIN (10 * 1000 * 1000)Generally, adding a prefix like
AR0521_to defines that are locally defined in a single file unnecessarily increases identifier length.It makes using short line lengths difficult.
Quoted 8 lines
e.g. Using this identifier anywhere
Quoted 1 line
+#define
AR0521_REG_HISPI_CONTROL_STATUS_FRAMER_TEST_MODE_ENABLE0x80Many of the 80 column line lengths and line wrapping used in this file are not really nice to read. I believe you don't have to be strict about 80 column lines.
Krzysztof first version had much longer lines, and in facts it has been asked by me to reduce them to 80 cols. The media subsystem requires to validate patches with
./scripts/checkpatch.pl --strict --max-line-length=80
We longly debated this and I believe it's now generally accepted to go over 80 when it makes sense, but not regularly span to 120 cols like in the previous version.
I think this 80-cols limit not being an hard limit anymore is doing more worse than good, as each subsystem applies a different rule, and I know how frustrating is for Krzysztof to be pushed in different direction, as the same happened to me when I contributed to other subsystems and I've been asked to span to 100 cols while I was trying to stay in 80 no matter what.
Thanks
j
Quoted 20 lines
Quoted 1 line
+#define be
cpu_to_be16It's a pity there's no way to declare an array with all members having a specific endianness. Making sure all elements in these arrays are declared with
be()is tedious.Quoted 1 line
+#define
AR0521_NUM_SUPPLIESARRAY_SIZE(ar0521_supply_names)It's almost always better to use
ARRAY_SIZEdirectly and not use a #define for the array size.drivers/media/i2c/ar0521.c
Quoted 2 lines
drivers/media/i2c/ar0521.c +2
-0+static int ar0521_set_gains (struct ar0521_dev *sensor) +{[]
drivers/media/i2c/ar0521.c
Quoted 1 line
drivers/media/i2c/ar0521.c +1
-0+dev_dbg (&sensor->i2c_client->dev,"%s()\n" , __func__);ftrace works and perhaps all the similar debug logging uses aren't really necessary.
Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
Quoted 2 lines · Jacopo Mondi
Hi Joe,
sorry to jump in
No worries. It's all just a bikeshed and doesn't really matter to the correctness of the code.
Quoted 32 lines · Joe Perches
Quoted 18 lines · Krzysztof Hałasa
Quoted 3 lines
The driver has been extensively tested in an i.MX6-based system. AR0521 is a 5.7 mm x 4.3 mm, 5 MPix RGGB MIPI/HiSPi BSI CMOS sensor from On Semiconductor.
trivial notes:
drivers/media/i2c/ar0521.c
Quoted 1 line
drivers/media/i2c/ar0521.c +0
-0[]
drivers/media/i2c/ar0521.c line 17
Quoted 2 lines
drivers/media/i2c/ar0521.c +2
-0+/* External clock (extclk) frequencies */ +#define AR0521_EXTCLK_MIN (10 * 1000 * 1000)Generally, adding a prefix like
AR0521_to defines that are locally defined in a single file unnecessarily increases identifier length.It makes using short line lengths difficult.
Quoted 8 lines
e.g. Using this identifier anywhere
Quoted 1 line
+#define
AR0521_REG_HISPI_CONTROL_STATUS_FRAMER_TEST_MODE_ENABLE0x80Many of the 80 column line lengths and line wrapping used in this file are not really nice to read. I believe you don't have to be strict about 80 column lines.
Krzysztof first version had much longer lines, and in facts it has been asked by me to reduce them to 80 cols. The media subsystem requires to validate patches with
Quoted 5 lines
./scripts/checkpatch.pl --strict --max-line-length=80We longly debated this and I believe it's now generally accepted to go over 80 when it makes sense, but not regularly span to 120 cols like in the previous version.
IMO: Many of the lines here could be lengthened to < 100 to improve readability.
Quoted 6 lines
I think this 80-cols limit not being an hard limit anymore is doing more worse than good, as each subsystem applies a different rule, and I know how frustrating is for Krzysztof to be pushed in different direction, as the same happened to me when I contributed to other subsystems and I've been asked to span to 100 cols while I was trying to stay in 80 no matter what.
Up to you all.
But there's a tension between long identifiers and short lines.
And anything using a 55 character identifier basically guarantees that the code will exceed 80 columns.
Using identifiers with 10 character or so is generally OK, but there are dozens of longer identifiers specific to this code.
I'd suggest because of these long identifiers that the code be restricted to 100 columns, but not strictly at 80.
And there are quite a few long lines in drivers/media/i2c and espcially for drivers/media/
A few of them are grotesquely long.
Probably all of them are historic and don't warrant change.
Just for i2c:
$ git ls-files -- 'drivers/media/i2c/*.[ch]' | \
xargs awk '{print length($0); }' | \
sort -rn | uniq -c
2 143
1 141
1 123
4 118
2 114
1 111
1 110
1 109
1 107
1 105
4 104
2 102
3 101
1 100
2 99
11 98
7 97
8 96
4 95
11 94
8 93
19 92
13 91
28 90
20 89
28 88
39 87
18 86
33 85
42 84
86 83
38 82
47 81
167 80
110 79
155 78
363 77
230 76
219 75
217 74
427 73
695 72
471 71
538 70
525 69
679 68
661 67
1046 66
757 65
1002 64
942 63
1053 62
967 61
1018 60
1132 59
1307 58
1366 57
3206 56
1240 55
2191 54
1829 53
1719 52
1503 51
1795 50
1714 49
1640 48
1567 47
1550 46
1880 45
2155 44
1780 43
1880 42
1854 41
1962 40
2031 39
2009 38
2022 37
2240 36
2252 35
2152 34
2178 33
2074 32
2185 31
2462 30
2478 29
2186 28
1988 27
1846 26
1926 25
2177 24
2048 23
1804 22
1267 21
1414 20
1563 19
6154 18
3619 17
7222 16
1682 15
2685 14
3037 13
2142 12
1704 11
3013 10
3191 9
1609 8
230 7
461 6
571 5
878 4
2790 3
6524 2
7732 1
24729 0And for all of drivers/media:
$ git ls-files -- 'drivers/media/*.[ch]' | \
xargs awk '{print length($0);}' | \
sort -rn | uniq -c
1 338
1 314
1 268
1 261
1 255
1 254
1 242
1 234
1 228
1 213
1 207
1 205
1 198
2 197
3 192
2 188
2 177
1 174
2 172
2 169
3 168
2 167
1 166
1 165
1 164
3 163
2 162
2 161
2 160
6 158
10 157
3 156
2 155
3 154
2 153
12 152
8 151
49 150
4 148
2 147
3 146
3 145
5 144
5 143
1 142
6 141
7 140
8 139
6 138
10 137
14 136
13 135
14 134
13 133
11 132
7 131
6 130
15 129
21 128
17 127
13 126
10 125
13 124
12 123
25 122
20 121
25 120
15 119
18 118
20 117
23 116
30 115
23 114
26 113
35 112
35 111
40 110
60 109
50 108
72 107
42 106
47 105
105 104
72 103
90 102
110 101
144 100
79 99
122 98
226 97
644 96
115 95
135 94
135 93
166 92
210 91
227 90
218 89
208 88
279 87
292 86
1260 85
1122 84
879 83
1288 82
1489 81
2505 80
6241 79
3653 78
5268 77
2012 76
2168 75
2279 74
3297 73
4343 72
3741 71
4018 70
4360 69
4487 68
4433 67
6014 66
6098 65
6547 64
6661 63
7312 62
7684 61
7610 60
8157 59
9052 58
10047 57
12064 56
9904 55
11075 54
11271 53
13259 52
11585 51
15036 50
13930 49
15159 48
14221 47
13349 46
14243 45
15887 44
17829 43
16620 42
17759 41
17569 40
16653 39
17386 38
17480 37
18296 36
18205 35
18782 34
18352 33
18137 32
19556 31
19229 30
19403 29
19570 28
19447 27
19581 26
19255 25
19300 24
17038 23
18523 22
15609 21
16188 20
14634 19
19426 18
20979 17
21548 16
13476 15
16713 14
18914 13
17577 12
12828 11
19525 10
21665 9
13912 8
3261 7
5375 6
6756 5
8260 4
23448 3
48708 2
55786 1
182329 0Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
In reply to Jacopo MondiQuoted 7 lines · Jacopo Mondi
The media subsystem requires to validate patches with
./scripts/checkpatch.pl --strict --max-line-length=80We longly debated this and I believe it's now generally accepted to go over 80 when it makes sense, but not regularly span to 120 cols like in the previous version.
Where is this documented and do you have a link to the debate?
The archive for the i2c mailing list doesn't show much debate:
https://lore.kernel.org/linux-i2c/?q=%2280+columns%22
https://lore.kernel.org/linux-i2c/?q=%22line+length%22
Perhaps there should be a MAINTAINERS P: entry for this requirement.
From MAINTAINERS:
P: Subsystem Profile document for more details submitting
patches to the given subsystem. This is either an in-tree file, or a URI. See Documentation/maintainer/maintainer-entry-profile.rst for details.
Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
Quoted 8 lines · Joe Perches
Quoted 7 lines · Jacopo Mondi
The media subsystem requires to validate patches with
./scripts/checkpatch.pl --strict --max-line-length=80We longly debated this and I believe it's now generally accepted to go over 80 when it makes sense, but not regularly span to 120 cols like in the previous version.
[]
Quoted 8 lines
Perhaps there should be a
MAINTAINERSP: entry for this requirement.From
MAINTAINERS:P: Subsystem Profile document for more details submitting
patches to the given subsystem. This is either an in-tree file, or a URI. SeeDocumentation/maintainer/maintainer-entry-profile.rstfor details.
Perhaps:
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -11977,6 +11977,7 @@ L: [email protected] S: Maintained W: https://linuxtv.org Q: http://patchwork.kernel.org/project/linux-media/list/ +P: https://linuxtv.org/downloads/v4l-dvb-apis-new/driver-api/maintainer-entry-profile.html T: git git://linuxtv.org/media_tree.git F: Documentation/admin-guide/media/ F: Documentation/devicetree/bindings/media/
Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
In reply to Joe PerchesHi Joe
Quoted 10 lines · Joe Perches
Quoted 7 lines · Jacopo Mondi
The media subsystem requires to validate patches with
./scripts/checkpatch.pl --strict --max-line-length=80We longly debated this and I believe it's now generally accepted to go over 80 when it makes sense, but not regularly span to 120 cols like in the previous version.
Where is this documented and do you have a link to the debate?
It's in the subsystem maintainer profile Documentation/driver-api/media/maintainer-entry-profile.rst
Where of course some exceptions are listed but it's anyway enforced that "efforts should be made towards staying within 80 characters per line"
- on strings, as they shouldn't be broken due to line length limits;
- when a function or variable name need to have a big identifier name, which keeps hard to honor the 80 columns limit;
- on arithmetic expressions, when breaking lines makes them harder to read;
- when they avoid a line to end with an open parenthesis or an open bracket.
The debate I mentioned was specifically on the previous version of the driver where me and Krzysztof shown quite different understanding of coding style requirements.
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
That lead me to submit this
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
which I never managed to re-send, my bad.
Quoted 16 lines
The archive for the i2c mailing list doesn't show much debate:
https://lore.kernel.org/linux-i2c/?q=%2280+columns%22
https://lore.kernel.org/linux-i2c/?q=%22line+length%22Perhaps there should be a
MAINTAINERSP: entry for this requirement.From
MAINTAINERS:P: Subsystem Profile document for more details submitting
patches to the given subsystem. This is either an in-tree file, or a URI. SeeDocumentation/maintainer/maintainer-entry-profile.rstfor details.
Re: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
Quoted 1 line · Jacopo Mondi
Hi Joe
hi again.
Quoted 27 lines · Joe Perches
Quoted 10 lines · Jacopo Mondi
Quoted 7 lines
The media subsystem requires to validate patches with
./scripts/checkpatch.pl --strict --max-line-length=80We longly debated this and I believe it's now generally accepted to go over 80 when it makes sense, but not regularly span to 120 cols like in the previous version.
Where is this documented and do you have a link to the debate?
It's in the subsystem maintainer profile
Documentation/driver-api/media/maintainer-entry-profile.rstWhere of course some exceptions are listed but it's anyway enforced that "efforts should be made towards staying within 80 characters per line"
- on strings, as they shouldn't be broken due to line length limits;
- when a function or variable name need to have a big identifier name, which keeps hard to honor the 80 columns limit;
- on arithmetic expressions, when breaking lines makes them harder to read;
- when they avoid a line to end with an open parenthesis or an open bracket.
Quoted 4 lines
The debate I mentioned was specifically on the previous version of the driver where me and Krzysztof shown quite different understanding of coding style requirements.
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
Thanks for that.
Quoted 2 lines
That lead me to submit this
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
That too.
FWIW, I believe using more than 100 columns or so makes it more difficult to track quickly and efficiently to the next line. Reading with multiple visual saccades on a single line is slow.
And IMO:
o reverse xmas tree declarations is quite a poor style requirement
o single line c99 // comments should be encouraged/preferred
o identifiers longer than 20 characters or so should be discouraged
Krzysztof Hałasa
maintainerRe: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
In reply to Jacopo MondiBeing that "stubborn developer"...
I think all those always increasing restrictions are a dead end and serve no useful purpose.
I strongly oppose restrictions which are just for the sake of uniformity. I think the coding style rules make sense only as long as they increase readability, and should never extend further. And in particular, we should NEVER sacrifice readability for uniformity.
Unfortunately one can't measure readability easily, and what's better for one, is worse for another (think - vision problems).
Yes, some arbitrary basic rules like tab size and brace style are needed, and there are certain rules needed for correctness (like "type* ptr" vs "type *ptr" which is quite visible in "type* a, b") but the rest should serve the readability. I.e., we shouldn't want to have all code identical - we should want it to be good.
E.g., for me, it's better to have 99 worse source files (like wildly formatted to 80 columns) and 1 (perhaps simply more recent) file with a better, cleaner formatting than to have 100 of the former kind.
But what do I know...
Signature · 5 lines
Krzysztof "Chris" Hałasa Sieć Badawcza Łukasiewicz Przemysłowy Instytut Automatyki i Pomiarów PIAP Al. Jerozolimskie 202, 02-486 Warszawa
Krzysztof Hałasa
maintainerRe: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
In reply to Joe PerchesHello Joe,
Quoted 6 lines · Joe Perches
drivers/media/i2c/ar0521.c line 17
Quoted 2 lines
drivers/media/i2c/ar0521.c new file +2
-0+/* External clock (extclk) frequencies */ +#define AR0521_EXTCLK_MIN (10 * 1000 * 1000)Generally, adding a prefix like
AR0521_to defines that are locally defined in a single file unnecessarily increases identifier length.
Right. In general, I don't do that (for that very reason), however in drivers/media this looks like a common practice and I didn't want to break it.
Quoted 3 lines
e.g. Using this identifier anywhere
Quoted 1 line
+#define
AR0521_REG_HISPI_CONTROL_STATUS_FRAMER_TEST_MODE_ENABLE0x80
Right. However, such a name helps looking this up in the docs. E.g. the register name in the docs is "hispi_control_status" and the bitfield is "framer_test_mode" or something like that. Since it's just one register (+ value) and it actually fits in 80 columns without too much problems, I'd rather like to leave it unchanged.
Quoted 3 lines
Many of the 80 column line lengths and line wrapping used in this file are not really nice to read. I believe you don't have to be strict about 80 column lines.
Well, personally I think we could all switch to VT100's 132 columns. Introduced in '78 :-) That's what I currently use for non-kernel tasks (not the VT100 but just the line length). OTOH I'm using that emacs wrapping mode so longer lines aren't a problem either.
But here, in drivers/media, I'm told 80 column is strict.
Quoted 5 lines
Quoted 1 line
+#define be
cpu_to_be16It's a pity there's no way to declare an array with all members having a specific endianness. Making sure all elements in these arrays are declared with
be()is tedious.
Right. Unfortunately anything else would mean recoding.
Quoted 4 lines
Quoted 1 line
+#define
AR0521_NUM_SUPPLIESARRAY_SIZE(ar0521_supply_names)It's almost always better to use
ARRAY_SIZEdirectly and not use a #define for the array size.
It's another custom in drivers/media, but I guess I don't have to follow it closely, do I? I never liked the #define.
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static int ar0521_set_gains(struct ar0521_dev *sensor) +{[]
Review
Quoted 1 line
(quoted diff) +1
-0+ dev_dbg(&sensor->i2c_client->dev, "%s()\n", __func__);ftrace works and perhaps all the similar debug logging uses aren't really necessary.
TBH I've never used ftrace.
It appears that it can't show the arguments, can it?
If not, I'd rather leave these dev_dbg()s in place - like other drivers/media/* in fact.
However obviously the code without deb_dbg()s would be cleaner, so if ftrace can show the (formatted) arguments, I'm all for it.
Thanks for looking at this,
Signature · 5 lines
Krzysztof "Chris" Hałasa Sieć Badawcza Łukasiewicz Przemysłowy Instytut Automatyki i Pomiarów PIAP Al. Jerozolimskie 202, 02-486 Warszawa
kernel test robot
build botRe: [PATCH v6 2/2] Driver for ON Semi AR0521 camera sensor
In reply to Krzysztof HałasaI love your patch! Yet something to improve:
Hi "Krzysztof,
I love your patch! Yet something to improve:
[auto build test ERROR on media-tree/master]
[also build test ERROR on linus/master v5.16-rc7 next-20211224] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Krzysztof-Ha-asa/On-Semi-AR0521-sensor-driver/20211223-150758 base: git://linuxtv.org/media_tree.git master config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20220101/202201010737.V5A5o9x5-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/664482ab74a2331a7a7ead9256b0455cfc3334c7 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Krzysztof-Ha-asa/On-Semi-AR0521-sensor-driver/20211223-150758 git checkout 664482ab74a2331a7a7ead9256b0455cfc3334c7 # save the config file to linux build tree mkdir build_dir make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from include/linux/device.h:25,
from include/linux/pm_runtime.h:11,
from drivers/media/i2c/ar0521.c:10:
>> drivers/media/i2c/ar0521.c:1029:21: error: initialization of 'int (*)(struct device *)' from incompatible pointer type 'void (*)(struct device *)' [-Werror=incompatible-pointer-types]
1029 | SET_RUNTIME_PM_OPS(ar0521_power_off, ar0521_power_on, NULL)
| ^~~~~~~~~~~~~~~~
include/linux/pm.h:341:21: note: in definition of macro 'SET_RUNTIME_PM_OPS'
341 | .runtime_suspend = suspend_fn, \
| ^~~~~~~~~~
drivers/media/i2c/ar0521.c:1029:21: note: (near initialization for 'ar0521_pm_ops.runtime_suspend')
1029 | SET_RUNTIME_PM_OPS(ar0521_power_off, ar0521_power_on, NULL)
| ^~~~~~~~~~~~~~~~
include/linux/pm.h:341:21: note: in definition of macro 'SET_RUNTIME_PM_OPS'
341 | .runtime_suspend = suspend_fn, \
| ^~~~~~~~~~cc1: some warnings being treated as errors
vim +1029 drivers/media/i2c/ar0521.c
1026
1027 static const struct dev_pm_ops ar0521_pm_ops = {
1028 SET_SYSTEM_SLEEP_PM_OPS(ar0521_suspend, ar0521_resume)
> 1029 SET_RUNTIME_PM_OPS(ar0521_power_off, ar0521_power_on, NULL)
1030 };
1031 static const struct of_device_id ar0521_dt_ids[] = {
1032 {.compatible = "onnn,ar0521"},
1033 {}
1034 };
1035 MODULE_DEVICE_TABLE(of, ar0521_dt_ids);
1036
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org