<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>arnavk23</title>
<link>https://arnavk23.github.io/blogs.html</link>
<atom:link href="https://arnavk23.github.io/blogs.xml" rel="self" type="application/rss+xml"/>
<description>Computer Science at IISER Bhopal. Quantum information, optimization in Julia, and the Linux kernel.</description>
<generator>quarto-1.10.19</generator>
<lastBuildDate>Sun, 25 Oct 2026 18:30:00 GMT</lastBuildDate>
<item>
  <title>A NAK, Some Homework, and Four More Fixes</title>
  <dc:creator>Arnav Kapoor</dc:creator>
  <link>https://arnavk23.github.io/posts/2026-10-26-sx93xx-fixes/</link>
  <description><![CDATA[ 





<p>A few days ago I <a href="../../posts/2026-10-22-lfx-kernel-mentorship/index.html">wrote</a> that kernel maintainers were much kinder than their reputation. This week a review of mine included the word “NAK”, followed by a homework assignment. I still stand by what I wrote.</p>
<p>Between 22 and 26 October, Jonathan Cameron applied four more of my patches to the <code>fixes-togreg</code> branch of <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/"><code>iio.git</code></a>. Three are in the Semtech SX9xxx capacitive proximity drivers (<code>sx9324</code>, <code>sx9360</code> and <code>sx9500</code>). The fourth is in the Microchip <code>mcp3564</code> ADC driver. All four are bug fixes with a <code>Fixes:</code> tag, and three of them are marked for stable kernels. Andy Shevchenko reviewed three of the four, and each review changed the patch for the better.</p>
<div class="cell" data-layout-align="default">
<div class="cell-output-display">
<div id="fig-timeline" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-timeline-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div>
<pre class="mermaid mermaid-js" data-label="fig-timeline">gantt
    todayMarker off
    dateFormat YYYY-MM-DD HH:mm
    axisFormat %d %b
    section sx9324
    v1 in review (NAK + homework) :done, 2026-10-22 04:24, 2026-10-24 00:56
    v2                            :active, 2026-10-24 00:56, 2026-10-24 07:27
    applied                       :milestone, 2026-10-24 07:27, 0d
    section mcp3564
    v1 in review (Reviewed-by)    :done, 2026-10-22 04:24, 2026-10-24 00:28
    v2                            :active, 2026-10-24 00:28, 2026-10-24 07:28
    applied                       :milestone, 2026-10-24 07:28, 0d
    section sx9360
    v1 in review                  :done, 2026-10-24 23:31, 2026-10-26 03:42
    v2                            :active, 2026-10-26 03:42, 2026-10-26 03:57
    applied                       :milestone, 2026-10-26 03:57, 0d
    section sx9500
    v1                            :active, 2026-10-24 23:26, 2026-10-26 05:07
    applied                       :milestone, 2026-10-26 05:07, 0d
</pre>
</div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-timeline-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: The four patches, from first submission to application (times in IST). Two of them needed a v2 after review; the sx9500 fix was applied as sent.
</figcaption>
</figure>
</div>
</div>
</div>
<section id="sx9324-a-table-that-was-half-as-long-as-it-should-be" class="level2">
<h2 class="anchored" data-anchor-id="sx9324-a-table-that-was-half-as-long-as-it-should-be">sx9324: a table that was half as long as it should be</h2>
<p>The SX9324 polls for new samples when it has no interrupt line. To decide how long to sleep, the driver reads the scan period code from a register and uses it as an index into a table:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb1-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> sx9324_wait_for_sample<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">struct</span> sx_common_data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>data<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-2"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-3">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">...</span></span>
<span id="cb1-4">    val <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> FIELD_GET<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>SX9324_REG_GNRL_CTRL0_SCANPERIOD_MASK<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> val<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-5"></span>
<span id="cb1-6">    msleep<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>sx9324_scan_period_table<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>val<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb1-7">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">...</span></span>
<span id="cb1-8"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
<p>The <code>SCANPERIOD</code> field is 5 bits wide, so it has 32 possible codes. The table had 16 entries. It had been copied from the SX9310 driver, where the same field is only 4 bits wide. Every code from <code>0x10</code> to <code>0x1f</code> read past the end of the array, and the chip’s reset default is <code>0x16</code> (100 ms). In other words, a polled SX9324 with the default configuration slept for whatever number happened to sit in memory after the table.</p>
<div id="fig-sx9324" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-sx9324-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://arnavk23.github.io/posts/2026-10-26-sx93xx-fixes/sx9324_table.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-sx9324-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: The scan period table before and after the fix. The old table covers only the first 16 codes; the reset default, <code>0x16</code>, is one of the codes that read past its end. The new values come from the period comments on the driver’s existing <code>sx9324_samp_freq_table[]</code>.
</figcaption>
</figure>
</div>
<p>The fix seemed simple: fill in all 32 periods, which the driver already documented in the comments of its <code>sx9324_samp_freq_table[]</code>, and add a <code>static_assert()</code> so the two tables can never disagree in length again. My v1 packed the 32 values into three lines, as tightly as they would fit. Andy’s reply was short:</p>
<blockquote class="blockquote">
<p>NAK to this hunk.<br>
Homework:<br>
read my comments regarding formatting such arrays in linux-iio@ mailing list<br>
for last calendar year or so and summarize the idea.</p>
</blockquote>
<p>That was my first NAK. To be honest it stung for a minute, and then I realised it was one of the most useful replies I had received. Andy hadn’t rewritten the table for me. He told me where the answer was and trusted me to find it. I replied within a few minutes to say I would do the homework.</p>
<p>I keep a local git mirror of the <a href="https://lore.kernel.org/linux-iio/">linux-iio archive</a>, so the homework was a search through a year of Andy’s reviews. The idea turned up again and again, most clearly in a <a href="https://lore.kernel.org/all/aRITLaJir-2IoclU@smile.fi.intel.com/">November 2025 review</a> of a new frequency driver:</p>
<blockquote class="blockquote">
<p>Make it power-of-two items per line, even with the comments to show the indexing, like<br>
<code>810, 1620, 2430, 3240, 4050, 4860, 5670, 6480,   /* 0 - 7 */</code></p>
</blockquote>
<p>Once I saw it, the reason was obvious. This table is indexed by a register value, so a reader has to be able to answer “what is entry <code>0x13</code>?” at a glance. With eight entries per line and the code range in a comment, you can. With values packed to fill the line, you have to count, and a typo can hide for years. The v2 looked like this:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb2-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">unsigned</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> sx9324_scan_period_table<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb2-2">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>          <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* 0x00 - 0x07 */</span></span>
<span id="cb2-3">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">22</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">26</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">34</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">38</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">46</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* 0x08 - 0x0f */</span></span>
<span id="cb2-4">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">56</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">62</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">68</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">74</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>       <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* 0x10 - 0x17 */</span></span>
<span id="cb2-5">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">400</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">800</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* 0x18 - 0x1f */</span></span>
<span id="cb2-6"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb2-7"></span>
<span id="cb2-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">static_assert</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>ARRAY_SIZE<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>sx9324_scan_period_table<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> ARRAY_SIZE<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>sx9324_samp_freq_table<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">));</span></span></code></pre></div></div>
<p>I also put the <code>static_assert()</code> on one line, as Andy suggested (“I would dare make it a single line”), added the <code>Fixes:</code> tag and <code>Cc: stable</code>, and rebased on <code>fixes-togreg</code>. Jonathan applied it a few hours after I sent it:</p>
<blockquote class="blockquote">
<p>Looks good and matches what Andy asked about.</p>
<p>Applied to the fixes-togreg branch of iio.git.</p>
</blockquote>
<p>Andy’s review of v2 arrived later that day. It had one more nit (“5 bit wide” should be “5-bit wide”) and ended with:</p>
<blockquote class="blockquote">
<p>Haven’t checked if this is part of any ABI. Otherwise LGTM,<br>
Reviewed-by: Andy Shevchenko &lt;andriy.shevchenko@intel.com&gt;</p>
</blockquote>
<p>Jonathan didn’t ask me for a v3 to fix a hyphen. He replied “Tweaked and tagged.” and fixed it himself in his tree. Going from NAK to <code>Reviewed-by:</code> in two days, with the maintainer cleaning up the last nit for me, felt like a real reward for doing the homework properly.</p>
</section>
<section id="mcp3564-a-null-pointer-behind-a-fallback" class="level2">
<h2 class="anchored" data-anchor-id="mcp3564-a-null-pointer-behind-a-fallback">mcp3564: a NULL pointer behind a fallback</h2>
<p>The MCP3564 driver identifies its chip by reading ID registers. If the ID is not one it knows, for example on a newer part number, it falls back to the match data from the device tree:</p>
<div class="cell" data-layout-align="default">
<div class="cell-output-display">
<div id="fig-mcp3564" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-mcp3564-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div>
<pre class="mermaid mermaid-js" data-label="fig-mcp3564">flowchart TD
    A[Read chip ID registers] --&gt; B{Known ID?}
    B -- yes --&gt; C[chip_info from the driver's table]
    B -- no --&gt; D["spi_get_device_match_data()"]
    D --&gt; E{NULL?}
    E -- "no: DT or id-table match" --&gt; F[use chip_info]
    E -- "yes: bound via driver_override" --&gt; G["before: oops on chip_info-&gt;have_vref&lt;br/&gt;after: return -ENODATA"]
</pre>
</div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-mcp3564-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: The probe path in mcp3564_config(). The fallback was the only path that didn’t check its result.
</figcaption>
</figure>
</div>
</div>
</div>
<p><code>spi_get_device_match_data()</code> returns NULL when the device was bound with <code>driver_override</code> and its name isn’t in the driver’s id table. The driver dereferenced the result unconditionally, so that case ended in a kernel oops. The fix is three lines:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode diff code-with-copy"><code class="sourceCode diff"><span id="cb3-1">        adc-&gt;chip_info = spi_get_device_match_data(adc-&gt;spi);</span>
<span id="cb3-2"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+       if (!adc-&gt;chip_info)</span></span>
<span id="cb3-3"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+           return -ENODATA;</span></span>
<span id="cb3-4"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-5">        adc-&gt;have_vref = adc-&gt;chip_info-&gt;have_vref;</span></code></pre></div></div>
<p>Andy gave it a <code>Reviewed-by:</code> on v1, together with a request and a thought about the bigger picture:</p>
<blockquote class="blockquote">
<p>Fine, but I hope we will have something to land to actually do it differently for the drivers that don’t want to use driver_override mechanism.</p>
<p>Reviewed-by: Andy Shevchenko &lt;andriy.shevchenko@intel.com&gt;<br>
Please, shrink the commit message to the point.</p>
</blockquote>
<p>He was right on both counts. A NULL check in every driver is a stopgap, not a design. And my v1 commit message took four paragraphs to say something that fits in one. The v2 message is half as long:</p>
<blockquote class="blockquote">
<p>When the chip can’t be identified from its ID registers, the driver falls back to spi_get_device_match_data() and dereferences the result unconditionally. That returns NULL for a device bound through driver_override whose name isn’t in the id table, causing an oops.</p>
<p>Return -ENODATA in that case.</p>
</blockquote>
<p>That taught me to write the shortest message that still explains the bug. Jonathan replied with a single word, “Applied”, which is my favourite word on the list.</p>
</section>
<section id="sx9360-a-frequency-that-always-became-zero" class="level2">
<h2 class="anchored" data-anchor-id="sx9360-a-frequency-that-always-became-zero">sx9360: a frequency that always became zero</h2>
<p>The SX9360 stores its scan period in two registers, <code>GNRL_CTRL1</code> and <code>GNRL_CTRL2</code>, as an 11-bit count of ticks. One tick is 8192 cycles of the 4 MHz oscillator. So the period for a frequency <em>f</em> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctext%7Bperiod%7D%20=%20%5Cfrac%7BF_%5Ctext%7BOSC%7D%7D%7B8192%20%5Ccdot%20f%7D.%0A"></p>
<p>The driver’s write function had the fraction upside down, and it scaled the micro-hertz part of the value wrongly:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb4-1">reg <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> val <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8192</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> SX9360_FOSC_HZ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> val2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8192</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>SX9360_FOSC_MHZ<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span></code></pre></div></div>
<p>For any frequency the chip supports, <code>val * 8192 / 4000000</code> is 0 in integer arithmetic. The <code>val2</code> term always produces a multiple of 2048, so it never reaches the 11-bit period field, but it does spill into the bits of <code>GNRL_CTRL1</code> above it. Above about 0.26 Hz of fractional part it also overflows an <code>int</code>. To make sure, I replayed both formulas for every frequency the driver advertises:</p>
<div id="fig-sx9360" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-sx9360-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://arnavk23.github.io/posts/2026-10-26-sx93xx-fixes/sx9360_freq.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-sx9360-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;4: The scan period programmed for each requested frequency. After the fix, the period follows FOSC / (8192 · f) across the whole 1 to 2047 tick range. Before the fix, the period field is 0 for every request, and for most of them stray bits are written to the upper part of <code>GNRL_CTRL1</code>.
</figcaption>
</figure>
</div>
<p>The new code computes the period the right way up, rounds to the closest tick, and rejects frequencies the chip can’t represent. While I was there, I noticed the advertised range didn’t match the comments next to it either: 4 MHz / 8192 is 488.28125 Hz, not 448.28125 Hz, and the minimum and step were wrong too. Before sending v1, I also checked in userspace that the default 102 ms period survived the round trip: 9.765625 Hz → period 50 → 9.765625 Hz.</p>
<p>Andy’s review of v1 was a series of short, precise questions:</p>
<blockquote class="blockquote">
<p><code>unsigned int period;</code></p>
<p>What’s the units for period? Seconds?</p>
</blockquote>
<blockquote class="blockquote">
<p><code>u64 freq_uhz;</code></p>
<p>_uHz</p>
</blockquote>
<blockquote class="blockquote">
<p><code>freq_uhz = (u64)val * MICRO + val2;</code></p>
<p>Read what units.h has for units of Hz.</p>
</blockquote>
<blockquote class="blockquote">
<p>Missing blank line. Always make guard()() to be standalone in the code.</p>
</blockquote>
<p>None of these change what the code does, but each makes it easier to read. A variable called <code>period</code> in a function full of hertz and oscillator cycles <em>should</em> make a reader ask “in what?”. <code>MICRO</code> is a plain number, while <code>MICROHZ_PER_HZ</code> from <code>&lt;linux/units.h&gt;</code> says what it is converting. So v2 renamed the variable to <code>period_ticks</code>, said in a comment what a tick is, switched to <code>freq_uHz</code> and <code>MICROHZ_PER_HZ</code>, and gave <code>guard(mutex)</code> a line of its own:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb5-1">    freq_uHz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>u64<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>val <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> MICROHZ_PER_HZ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> val2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-2">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(!</span>freq_uHz<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb5-3">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>EINVAL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-4"></span>
<span id="cb5-5">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* The register holds the scan period in ticks of 8192 FOSC cycles. */</span></span>
<span id="cb5-6">    period_ticks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> DIV64_U64_ROUND_CLOSEST<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span>u64<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>SX9360_FOSC_HZ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> MICROHZ_PER_HZ<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb5-7">                           freq_uHz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8192</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(!</span>period_ticks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> period_ticks <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> SX9360_REG_GNRL_SCANPERIOD_MAX<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb5-9">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>EINVAL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-10"></span>
<span id="cb5-11">    buf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cpu_to_be16<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>period_ticks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-12"></span>
<span id="cb5-13">    guard<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>mutex<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(&amp;</span>data<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>mutex<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span></code></pre></div></div>
<p>Andy also suggested that “at some point” the frequency table should become a plain array of ints. That is a cleanup rather than a fix, so I left it for a separate patch and said so below the <code>---</code> line. Fifteen minutes after I sent v2, Jonathan replied:</p>
<blockquote class="blockquote">
<p>Seems like you’ve addressed Andy’s comments (except for the ‘at some point’ one which is fine to leave for now). Looks good to me, so rather than keep track of this one I’m going to speculatively apply it to the fixes-togreg branch of iio.git and mark it for stable.</p>
</blockquote>
<p>“Rather than keep track of this one” is a small phrase, but it says a lot. A maintainer has hundreds of threads to track, and a patch that clearly answers every review comment is one he can take off his list straight away. Writing a precise changelog is how I can make that easier for him.</p>
</section>
<section id="sx9500-reference-counts-that-drift" class="level2">
<h2 class="anchored" data-anchor-id="sx9500-reference-counts-that-drift">sx9500: reference counts that drift</h2>
<p>The SX9500 driver keeps reference counts of who is using each channel and the close/far interrupt. A channel is powered on when its count goes from 0 to 1, and off when it drops back to 0. <code>sx9500_write_event_config()</code> incremented or decremented these counts on <em>every</em> write to an event’s <code>en</code> attribute, even when the event was already in the requested state.</p>
<p>That lets the counts drift away from reality. Writing 0 to an event that is already disabled takes the count to −1. A following write of 1 brings it back to 0, which is not the 0 → 1 transition that turns the channel on. The event now reads as enabled, but the channel and its interrupt are off. Because raw reads share <code>channel_users[]</code>, a raw read can then wait forever for a conversion that never starts. Writing 1 twice and then 0 does the opposite: the event reads as disabled but the channel stays on.</p>
<div id="fig-sx9500" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-sx9500-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://arnavk23.github.io/posts/2026-10-26-sx93xx-fixes/sx9500_counts.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-sx9500-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;5: <code>channel_users[]</code> for two write sequences. Before the fix (red), redundant writes move the count, and the event state and channel power end up disagreeing. After the fix (blue, dashed), a write that doesn’t change state returns early.
</figcaption>
</figure>
</div>
<p>The newer SX9xxx drivers share <code>sx_common_write_event_config()</code>, which already returns early when the state doesn’t change. The SX9500 predates that common code, so the fix brings it in line:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode diff code-with-copy"><code class="sourceCode diff"><span id="cb6-1">    mutex_lock(&amp;data-&gt;mutex);</span>
<span id="cb6-2"></span>
<span id="cb6-3"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   /* The user counts must only change when the state does. */</span></span>
<span id="cb6-4"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   if (data-&gt;event_enabled[chan-&gt;channel] == state) {</span></span>
<span id="cb6-5"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+       ret = 0;</span></span>
<span id="cb6-6"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+       goto out_unlock;</span></span>
<span id="cb6-7"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   }</span></span>
<span id="cb6-8"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb6-9">    if (state) {</span></code></pre></div></div>
<p>I don’t have SX9500 hardware, so I checked both write sequences with a userspace model of the counting and said exactly that below the <code>---</code> line. This was the only one of the four that went in as first sent. Jonathan’s reply in full:</p>
<blockquote class="blockquote">
<p>Applied and marked for stable.</p>
<p>thanks</p>
<p>Jonathan</p>
</blockquote>
<p>I hadn’t added <code>Cc: stable</code> to this one. Jonathan decided it deserved a backport and added the tag himself.</p>
</section>
<section id="what-these-reviews-taught-me" class="level2">
<h2 class="anchored" data-anchor-id="what-these-reviews-taught-me">What these reviews taught me</h2>
<p>Looking back over the four threads, very few of the review comments were about whether the code worked. They were about whether the <em>next</em> person could read it:</p>
<div id="tbl-review" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-review-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: The review comments on the four patches, and how each was addressed.
</figcaption>
<div aria-describedby="tbl-review-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Patch</th>
<th>Review comment</th>
<th>What I changed</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>sx9324</td>
<td>Table formatting: NAK + homework</td>
<td>8 entries per line with index comments</td>
</tr>
<tr class="even">
<td>sx9324</td>
<td><code>static_assert()</code> on one line</td>
<td>Joined the line</td>
</tr>
<tr class="odd">
<td>sx9324</td>
<td>“5 bit” → “5-bit”</td>
<td>Jonathan fixed it while applying</td>
</tr>
<tr class="even">
<td>mcp3564</td>
<td>“Shrink the commit message to the point”</td>
<td>Four paragraphs → two</td>
</tr>
<tr class="odd">
<td>sx9360</td>
<td>Units for <code>period</code>?</td>
<td><code>period_ticks</code> and a comment saying what a tick is</td>
</tr>
<tr class="even">
<td>sx9360</td>
<td><code>_uHz</code>, use <code>units.h</code></td>
<td><code>freq_uHz</code>, <code>MICROHZ_PER_HZ</code></td>
</tr>
<tr class="odd">
<td>sx9360</td>
<td><code>guard()()</code> must stand alone</td>
<td>Added a blank line</td>
</tr>
<tr class="even">
<td>sx9360</td>
<td>Table should be a plain int array</td>
<td>Deferred to a later cleanup, with agreement</td>
</tr>
</tbody>
</table>
</div>
</figure>
</div>
<p>A few habits came out of this week:</p>
<ul>
<li><strong>When a reviewer points you at the archive, read the archive.</strong> Andy’s homework took me longer than rewriting the table myself would have. But now I know a rule he applies to every indexed table, and I won’t need to be told again.</li>
<li><strong>Units belong in names.</strong> <code>period_ticks</code>, <code>freq_uHz</code> and <code>MICROHZ_PER_HZ</code> make the code document itself.</li>
<li><strong>The changelog is part of the patch.</strong> Each v2 listed every comment and who made it, and said what I hadn’t done and why. That is what let Jonathan apply the sx9360 fix fifteen minutes after it arrived.</li>
<li><strong>Say what you tested.</strong> All four patches say “Compile-tested only” under the <code>---</code> line, along with whatever checking I could do without the hardware. Maintainers can only judge the risk of a patch if you’re honest about this.</li>
</ul>
</section>
<section id="results" class="level2">
<h2 class="anchored" data-anchor-id="results">Results</h2>
<div id="tbl-results" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-results-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;2: The four patches applied this week. Jonathan plans to rebase <code>fixes-togreg</code> on rc1, so the commit IDs may change.
</figcaption>
<div aria-describedby="tbl-results-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<thead>
<tr class="header">
<th>Patch</th>
<th>Tree</th>
<th>Reviewed by</th>
<th>Links</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>sx9324: fix out-of-bounds read of scan period table</td>
<td>iio fixes, stable</td>
<td>Andy Shevchenko</td>
<td><a href="https://lore.kernel.org/all/20261021225417.626946-1-kapoorarnav43@gmail.com/">v1</a> · <a href="https://lore.kernel.org/all/20261023192700.221344-1-kapoorarnav43@gmail.com/">v2</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=9cc70d11f23c">commit</a></td>
</tr>
<tr class="even">
<td>mcp3564: reject devices without match data</td>
<td>iio fixes</td>
<td>Andy Shevchenko</td>
<td><a href="https://lore.kernel.org/all/20261021225431.627718-1-kapoorarnav43@gmail.com/">v1</a> · <a href="https://lore.kernel.org/all/20261023185837.195943-1-kapoorarnav43@gmail.com/">v2</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=bee7b8b5c5d0">commit</a></td>
</tr>
<tr class="odd">
<td>sx9360: fix sampling frequency write and available range</td>
<td>iio fixes, stable</td>
<td>Andy Shevchenko (v1)</td>
<td><a href="https://lore.kernel.org/all/20261024180149.144609-1-kapoorarnav43@gmail.com/">v1</a> · <a href="https://lore.kernel.org/all/20261025221241.19596-1-kapoorarnav43@gmail.com/">v2</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=065605c6a43b">commit</a></td>
</tr>
<tr class="even">
<td>sx9500: ignore event config writes that don’t change state</td>
<td>iio fixes, stable</td>
<td>—</td>
<td><a href="https://lore.kernel.org/all/20261024175658.130546-1-kapoorarnav43@gmail.com/">patch</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=09f742b49cb2">commit</a></td>
</tr>
</tbody>
</table>
</div>
</figure>
</div>
<p>That brings my total to thirteen applied patches. I have a few more SX9xxx patches on the list as I write this, a series that keeps the IRQ balanced across suspend and resume, and a hysteresis fix for the <code>sx9310</code>, so this family of drivers may get one more post.</p>
</section>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>Thank you to Andy Shevchenko, whose reviews are short, exact and always worth reading twice, and to Jonathan Cameron for his patience, his speed, and for fixing my hyphens. Thanks also to Shuah Khan for the mentorship that got me here.</p>


</section>

 ]]></description>
  <category>linux-kernel</category>
  <category>lfx</category>
  <category>iio</category>
  <category>open-source</category>
  <guid>https://arnavk23.github.io/posts/2026-10-26-sx93xx-fixes/</guid>
  <pubDate>Sun, 25 Oct 2026 18:30:00 GMT</pubDate>
  <media:content url="https://arnavk23.github.io/posts/2026-10-26-sx93xx-fixes/sx9324_table.png" medium="image" type="image/png" height="49" width="144"/>
</item>
<item>
  <title>Learnings from LKMP: How to contribute to the Linux Kernel</title>
  <dc:creator>Arnav Kapoor</dc:creator>
  <link>https://arnavk23.github.io/posts/2026-10-22-lfx-kernel-mentorship/</link>
  <description><![CDATA[ 





<p>Kernel developers have a reputation for being hard on newcomers. My experience was the opposite. Over the <a href="https://wiki.linuxfoundation.org/lkmp">LFX Linux Kernel Bug Fixing Mentorship</a> with Shuah Khan, nine of my patches were applied upstream: eight in the Industrial I/O (IIO) subsystem and one in the <code>sfc</code> network driver. None of them reached that state as I first wrote them. Each was improved by someone on the mailing list: a maintainer, a reviewer, or an automated test robot. This post is an account of that collaboration as much as of the bugs themselves.</p>
<section id="background-how-a-patch-travels" class="level2">
<h2 class="anchored" data-anchor-id="background-how-a-patch-travels">Background: how a patch travels</h2>
<p>The Linux kernel has no pull requests. A change is a plain-text email, sent with <code>git send-email</code> to the maintainers and lists that <code>scripts/get_maintainer.pl</code> names for the files it touches. Reviewers reply inline, and they show approval with tags such as <code>Reviewed-by:</code> and <code>Acked-by:</code>. A subsystem maintainer then applies the patch to their own tree. From there it flows into <a href="https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/">linux-next</a>, then into Linus Torvalds’ mainline tree during a merge window, and, if it is marked for stable, into the <a href="https://www.kernel.org/category/releases.html">stable kernels</a> people already run.</p>
<div class="cell" data-layout-align="default">
<div class="cell-output-display">
<div id="fig-flow" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-flow-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div>
<pre class="mermaid mermaid-js" data-label="fig-flow">flowchart LR
    A[Prepare&lt;br/&gt;and check] --&gt; B[Send to&lt;br/&gt;the list]
    B --&gt; C{Review}
    C -- v2 --&gt; C
    C -- tags --&gt; D[Maintainer&lt;br/&gt;tree]
    D --&gt; E[linux-next]
    E --&gt; F[Mainline]
    D -. stable .-&gt; G[Stable&lt;br/&gt;kernels]
</pre>
</div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-flow-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: The path every patch in this post followed. Preparing means building with W=1 and running checkpatch and kernel-doc; the review loop is where most of the work happened.
</figcaption>
</figure>
</div>
</div>
</div>
<p>IIO, maintained by Jonathan Cameron in <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/"><code>iio.git</code></a>, has two main branches. Fixes go to <code>fixes-togreg</code> and reach mainline in the current release cycle. Everything else goes to <code>togreg</code>, through a <code>testing</code> branch, and waits for the next merge window. This distinction matters later in the story.</p>
</section>
<section id="learning-the-process-the-hard-way" class="level2">
<h2 class="anchored" data-anchor-id="learning-the-process-the-hard-way">Learning the process the hard way</h2>
<p>My first attempt, in June 2025, did not reach any maintainer: I sent it as an attachment, only to my mentor. A second round, in June 2026, targeted the <code>sm750fb</code> staging driver. I had based it on an old tree, so I was renaming variables that other contributors had already renamed. The <a href="https://github.com/intel/lkp-tests">kernel test robot</a> reported build failures, and my duplicate resubmissions earned a polite request to stop.</p>
<p>These were useful failures. They set the method I used for every later patch:</p>
<ol type="1">
<li>Start from today’s linux-next or the subsystem tree, never a stale checkout.</li>
<li>Build each changed object with <code>make W=1</code>, run <code>scripts/checkpatch.pl --strict</code>, and, for documentation, <code>scripts/kernel-doc -Wall</code> over the whole driver.</li>
<li>Search the list archives first. I kept local git mirrors of the <a href="https://lore.kernel.org/linux-iio/">linux-iio</a> and <a href="https://lore.kernel.org/netdev/">netdev</a> archives from lore.kernel.org, so I could check whether someone was already working on the same code.</li>
<li>Send each version once, with a changelog under the <code>---</code> line.</li>
</ol>
</section>
<section id="finding-bugs-worth-fixing" class="level2">
<h2 class="anchored" data-anchor-id="finding-bugs-worth-fixing">Finding bugs worth fixing</h2>
<p>Most of my search time went into static analysis: <a href="https://repo.or.cz/smatch.git">Smatch</a>, <a href="https://coccinelle.gitlabpages.inria.fr/website/">Coccinelle</a>, <code>W=1</code> builds and kernel-doc. Most of what these tools report is not a bug. I went through Smatch’s 114 warnings on <code>net/</code> and about 20 in IIO. In every case I checked, the code was correct: a signedness warning caused by a <code>__be16</code> enum, a pointer that a helper function initialised where Smatch could not see it, and similar. Telling a false positive from a real defect, and dropping it quickly, turned out to be one of the most important skills of the mentorship.</p>
<p>Three real bugs came out of this search. Each of them also taught me something about how C code can hide errors.</p>
<section id="silent-truncation-in-scmi_sensors" class="level3">
<h3 class="anchored" data-anchor-id="silent-truncation-in-scmi_sensors">Silent truncation in <code>scmi_sensors</code></h3>
<p>The kernel test robot had reported <code>do_div()</code> warnings in the <a href="https://developer.arm.com/Architectures/System%20Control%20and%20Management%20Interface">SCMI</a> sensor driver, and Geert Uytterhoeven had noted on the list that most <code>do_div()</code> uses in that driver were broken. Nobody had fixed them.</p>
<p><code>do_div(n, base)</code> divides a 64-bit dividend by a <em>32-bit</em> divisor: <code>base</code> is stored in a <code>uint32_t</code> on every architecture. The driver passed 64-bit divisors in seven calls. One of them converts a sensor’s update interval to a sampling frequency:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb1-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span> convert_ns_to_freq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>u64 interval_ns<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> u64 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>hz<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> u64 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>uhz<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-2"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-3">    u64 rem<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> freq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-4"></span>
<span id="cb1-5">    freq <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> NSEC_PER_SEC<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-6">    rem <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> do_div<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>freq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> interval_ns<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* interval_ns silently truncated to 32 bits */</span></span>
<span id="cb1-7">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>hz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> freq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-8">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>uhz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rem <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000000</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-9">    do_div<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(*</span>uhz<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> interval_ns<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-10"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
<p>For any interval of 2³² ns (about 4.29 s) or longer, the divisor wraps around. Figure&nbsp;2 shows the result. The reported frequency is correct up to 4.29 s, then jumps by orders of magnitude, and an interval that is an exact multiple of 2³² ns would divide by zero.</p>
<div id="fig-dodiv" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-dodiv-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://arnavk23.github.io/posts/2026-10-22-lfx-kernel-mentorship/do_div.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-dodiv-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Sampling frequency reported by <code>convert_ns_to_freq()</code> as a function of the sensor update interval. Before the fix, the divisor is reduced modulo 2³², so the result is wrong past 4.29 s and diverges near every multiple of 2³² ns (dotted lines).
</figcaption>
</figure>
</div>
<p>The fix replaces each call with <code>div64_u64()</code> or <code>div64_u64_rem()</code>, which take a 64-bit divisor. The functions are not drop-in replacements, though. <code>do_div()</code> modifies its first argument in place and <em>returns the remainder</em>, while <code>div64_u64()</code> <em>returns the quotient</em>. I rewrote each call site separately so it kept its meaning:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode diff code-with-copy"><code class="sourceCode diff"><span id="cb2-1"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-   freq = NSEC_PER_SEC;</span></span>
<span id="cb2-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-   rem = do_div(freq, interval_ns);</span></span>
<span id="cb2-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-   *hz = freq;</span></span>
<span id="cb2-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-   *uhz = rem * 1000000UL;</span></span>
<span id="cb2-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-   do_div(*uhz, interval_ns);</span></span>
<span id="cb2-6"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   *hz = div64_u64_rem(HZ_PER_GHZ, interval_ns, &amp;rem);</span></span>
<span id="cb2-7"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   *uhz = div64_u64(rem * MICROHZ_PER_HZ, interval_ns);</span></span></code></pre></div></div>
<p>Andy Shevchenko’s review of v1 pointed out over-long lines, asked for the named unit constants (<code>HZ_PER_GHZ</code>, <code>MICROHZ_PER_HZ</code>) instead of bare literals, and corrected the format of my <code>Assisted-by:</code> tag. The v2 got his <code>Reviewed-by:</code>, and Jonathan applied it to <code>fixes-togreg</code> with <code>Cc: stable</code> (<a href="https://lore.kernel.org/all/20261006045244.13993-1-kapoorarnav43@gmail.com/">lore</a>, <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=850040f34265">commit</a>).</p>
</section>
<section id="three-axes-one-calibration-value" class="level3">
<h3 class="anchored" data-anchor-id="three-axes-one-calibration-value">Three axes, one calibration value</h3>
<p>The InvenSense MPU-9250 combines an accelerometer and gyroscope with an AK8963 magnetometer. Each magnetometer axis has its own factory sensitivity adjustment, called ASAX, ASAY and ASAZ in the datasheet. The driver computes one scale per axis into <code>magn_raw_to_gauss[]</code> and reads it back with <code>chan-&gt;address</code> as the index. But the channel macro never set <code>.address</code>, so it was 0 on all three channels. The Y and Z axes were scaled with the X axis’s calibration, and had been since 2019.</p>
<p>I wanted to be certain before reporting this, so I inspected the compiled channel tables with gdb rather than reasoning from the source alone:</p>
<div id="tbl-magn" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-magn-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Magnetometer channel addresses read from the compiled object with gdb.
</figcaption>
<div aria-describedby="tbl-magn-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Channel</th>
<th><code>.address</code> before</th>
<th><code>.address</code> after</th>
<th>Calibration used before fix</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>in_magn_x</code></td>
<td>0</td>
<td>0</td>
<td>ASAX (correct)</td>
</tr>
<tr class="even">
<td><code>in_magn_y</code></td>
<td>0</td>
<td>1</td>
<td>ASAX (wrong)</td>
</tr>
<tr class="odd">
<td><code>in_magn_z</code></td>
<td>0</td>
<td>2</td>
<td>ASAX (wrong)</td>
</tr>
</tbody>
</table>
</div>
</figure>
</div>
<p>The fix is a single line in the macro, <code>.address = (_chan2) - IIO_MOD_X</code>, which maps X, Y and Z to 0, 1 and 2 in the same order <code>inv_magn_init()</code> fills the array (<a href="https://lore.kernel.org/all/20261011045619.357261-1-kapoorarnav43@gmail.com/">lore</a>, <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=14265c34a218">commit</a>).</p>
</section>
<section id="positional-initialisers-and-swapped-startup-times" class="level3">
<h3 class="anchored" data-anchor-id="positional-initialisers-and-swapped-startup-times">Positional initialisers and swapped startup times</h3>
<p>While reading the same driver, I noticed a quieter problem. The hardware description struct declares the startup times in one order:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb3-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">struct</span> inv_mpu6050_hw <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-2">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">...</span></span>
<span id="cb3-3">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">struct</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-4">        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">unsigned</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> accel<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-5">        <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">unsigned</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> gyro<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-6">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> startup_time<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-7"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span></code></pre></div></div>
<p>But every entry of the <code>hw_info[]</code> table filled them in the opposite order:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode diff code-with-copy"><code class="sourceCode diff"><span id="cb4-1"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-   .startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},</span></span>
<span id="cb4-2"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   .startup_time = {</span></span>
<span id="cb4-3"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+       .accel = INV_MPU6500_ACCEL_STARTUP_TIME,</span></span>
<span id="cb4-4"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+       .gyro = INV_MPU6500_GYRO_STARTUP_TIME,</span></span>
<span id="cb4-5"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">+   },</span></span></code></pre></div></div>
<p>C positional initialisers assign values by position, not by meaning, so the compiler had no reason to complain. The accelerometer and gyroscope startup times had been swapped for all 19 supported chips since 2021. Using designated initialisers fixes the bug and makes the same mistake impossible to repeat.</p>
<p>Jean-Baptiste Maneyrol, the driver’s maintainer at TDK InvenSense, acked both <code>inv_mpu6050</code> fixes. Jonathan applied them to <code>fixes-togreg</code>, marked for stable (<a href="https://lore.kernel.org/all/20261011045710.357809-1-kapoorarnav43@gmail.com/">lore</a>, <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=2b8d4cd20ac8">commit</a>).</p>
</section>
</section>
<section id="documentation-and-why-reviewers-ask-for-more" class="level2">
<h2 class="anchored" data-anchor-id="documentation-and-why-reviewers-ask-for-more">Documentation, and why reviewers ask for more</h2>
<p>The remaining patches fixed kernel-doc comments that no longer matched the code: members that had been renamed or removed in <code>ad5686</code>, <code>inv_icm42600</code>, <code>inv_mpu6050</code>, and <code>sfc</code>. These sound minor, but the review of these patches taught me the most about how maintainers think.</p>
<p>When I sent a one-line fix for a stale <code>@vdd_supply</code> comment in <code>inv_icm42600</code>, Andy gave it a <code>Reviewed-by:</code> and asked whether it was the only kernel-doc problem in the driver. It was not. My v2 became a two-patch series that left the driver clean under <code>kernel-doc -Wall</code>. From then on I checked the whole driver before sending any documentation patch, and the <code>inv_mpu6050</code> patch fixed all 13 of its warnings at once.</p>
<p>On netdev, Simon Horman noticed that a member next to the ones I had fixed in <code>sfc</code> was also undocumented. Looking closer, it was not used anywhere, so v2 removed it and two other unused members. That patch got <code>Reviewed-by:</code> tags from Alex Austin at AMD and from Simon, and Paolo Abeni applied it to <code>net-next</code> (<a href="https://lore.kernel.org/all/20261007175338.28683-1-kapoorarnav43@gmail.com/">lore</a>, <a href="https://git.kernel.org/netdev/net-next/c/32a8010d2c30">commit</a>). It was my first patch applied anywhere in the kernel.</p>
</section>
<section id="working-with-the-maintainers" class="level2">
<h2 class="anchored" data-anchor-id="working-with-the-maintainers">Working with the maintainers</h2>
<p>I was nervous before every early submission. The names on the <code>To:</code> line were names I knew from <code>MAINTAINERS</code> files and commit logs, and every reply would be public and archived. That nervousness faded as the replies came in, because they were generous and precise.</p>
<p>Jonathan made me feel welcome from the start. When Jean-Baptiste called the startup-time fix “another good catch”, Jonathan replied “Absolutely” and applied it. He then suggested a follow-up, using named initialisers for the neighbouring <code>.temp</code> field, and added “No problem if you have moved onto other things!” It was a small sentence, but it made me feel like a contributor rather than a student.</p>
<p>He was also careful in ways that taught me about stewardship. On the <code>cros_ec_sensors</code> patch he wrote that the driver “tends to be well maintained”, so he would wait for its own maintainers before applying it. Tzung-Bi Shih, a ChromeOS EC maintainer, reviewed it the next morning, and Jonathan applied it that evening. When Joshua Crofts asked me for a <code>Fixes:</code> tag on that patch, I traced the code back to the commit that introduced it and posted the tag in the thread. Andy replied that there was no need to resend, because <code>b4</code> collects tags from the whole thread. These are small things, but each of them is part of how the community works.</p>
<p>The best moment was a run of emails late on 17 October. Within about twenty minutes, “Applied to the togreg branch of iio.git” and “Applied to the fixes-togreg branch” arrived for seven of my patches. I was thrilled. After the earlier failures, seeing them applied one after another was the high point of the mentorship.</p>
<div class="cell" data-layout-align="default">
<div class="cell-output-display">
<div id="fig-timeline" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-timeline-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div>
<pre class="mermaid mermaid-js" data-label="fig-timeline">gantt
    dateFormat YYYY-MM-DD
    axisFormat %d %b
    section net-next
    sfc kernel-doc (v1, v2)        :done, 2026-10-03, 2026-10-13
    applied                        :milestone, 2026-10-13, 0d
    section iio fixes-togreg
    scmi_sensors (v1, v2)          :done, 2026-10-03, 2026-10-17
    mpu6050 magnetometer scale     :done, 2026-10-11, 2026-10-17
    mpu6050 startup times          :done, 2026-10-11, 2026-10-17
    cros_ec CALIBSCALE             :done, 2026-10-11, 2026-10-18
    applied                        :milestone, 2026-10-17, 0d
    section iio togreg
    icm42600 kernel-doc (v1, v2)   :done, 2026-10-03, 2026-10-17
    ad5686 kernel-doc              :done, 2026-10-11, 2026-10-17
    mpu6050 kernel-doc             :done, 2026-10-11, 2026-10-17
    section in review
    mpu6050 named .temp            :active, 2026-10-18, 2026-10-22
</pre>
</div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-timeline-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: From first submission to application, October 2026. Bars span first submission to application; diamonds mark the main application days.
</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="a-lesson-in-dependencies" class="level2">
<h2 class="anchored" data-anchor-id="a-lesson-in-dependencies">A lesson in dependencies</h2>
<p>The follow-up Jonathan suggested taught me one more thing. I based it on <code>fixes-togreg</code>, because it edits lines that the startup-time fix had just changed. Joshua tried it on the development branch and replied that it did not apply. The patch was fine, but its context lines only exist where the startup-time fix exists. I explained this on the list. The lesson is to always state a patch’s base branch and dependencies below the <code>---</code> line, especially when it builds on a fix that has not yet reached the development branch.</p>
</section>
<section id="on-using-an-ai-assistant" class="level2">
<h2 class="anchored" data-anchor-id="on-using-an-ai-assistant">On using an AI assistant</h2>
<p>I used an LLM-based assistant for analysis and to check my reasoning, and I disclosed it with an <code>Assisted-by:</code> tag on each patch, as the kernel’s <a href="https://docs.kernel.org/process/coding-assistants.html">policy on coding assistants</a> requires. That policy is clear that responsibility stays with the human: I signed off, built and tested every patch, and answered every review myself. The guidance on the tag’s format changed during the mentorship. Andy corrected my early format, and Jonathan later dropped the tag from one patch because the guidance had changed again. It is a policy still being worked out, and the community is working it out in public.</p>
</section>
<section id="results" class="level2">
<h2 class="anchored" data-anchor-id="results">Results</h2>
<div id="tbl-results" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-results-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;2: All nine applied patches.
</figcaption>
<div aria-describedby="tbl-results-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<thead>
<tr class="header">
<th>Patch</th>
<th>Tree</th>
<th>Reviewed / acked by</th>
<th>Links</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>scmi_sensors: fix truncating 64-bit divisions</td>
<td>iio fixes, stable</td>
<td>Andy Shevchenko</td>
<td><a href="https://lore.kernel.org/all/20261006045244.13993-1-kapoorarnav43@gmail.com/">lore</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=850040f34265">commit</a></td>
</tr>
<tr class="even">
<td>inv_mpu6050: fix magnetometer scale of Y and Z axes</td>
<td>iio fixes, stable</td>
<td>Jean-Baptiste Maneyrol</td>
<td><a href="https://lore.kernel.org/all/20261011045619.357261-1-kapoorarnav43@gmail.com/">lore</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=14265c34a218">commit</a></td>
</tr>
<tr class="odd">
<td>inv_mpu6050: fix swapped accel and gyro startup times</td>
<td>iio fixes, stable</td>
<td>Jean-Baptiste Maneyrol</td>
<td><a href="https://lore.kernel.org/all/20261011045710.357809-1-kapoorarnav43@gmail.com/">lore</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=2b8d4cd20ac8">commit</a></td>
</tr>
<tr class="even">
<td>cros_ec_sensors: sensor_scale for CALIBSCALE</td>
<td>iio fixes</td>
<td>Joshua Crofts, Tzung-Bi Shih</td>
<td><a href="https://lore.kernel.org/all/20261011045410.356156-1-kapoorarnav43@gmail.com/">lore</a> · <a href="https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=489856f8d455">commit</a></td>
</tr>
<tr class="odd">
<td>sfc: fix stale kernel-doc in net_driver.h</td>
<td>net-next</td>
<td>Alex Austin, Simon Horman</td>
<td><a href="https://lore.kernel.org/all/20261007175338.28683-1-kapoorarnav43@gmail.com/">lore</a> · <a href="https://git.kernel.org/netdev/net-next/c/32a8010d2c30">commit</a></td>
</tr>
<tr class="even">
<td>inv_icm42600: fix kernel-doc warnings (2 patches)</td>
<td>iio togreg</td>
<td>Andy Shevchenko, Joshua Crofts</td>
<td><a href="https://lore.kernel.org/all/20261006045413.14320-1-kapoorarnav43@gmail.com/">lore</a></td>
</tr>
<tr class="odd">
<td>ad5686: fix channels member name in kernel-doc</td>
<td>iio togreg</td>
<td>Maxwell Doose, Nuno Sá</td>
<td><a href="https://lore.kernel.org/all/20261011045149.353929-1-kapoorarnav43@gmail.com/">lore</a></td>
</tr>
<tr class="even">
<td>inv_mpu6050: fix kernel-doc warnings</td>
<td>iio togreg</td>
<td>Joshua Crofts</td>
<td><a href="https://lore.kernel.org/all/20261011045754.358335-1-kapoorarnav43@gmail.com/">lore</a></td>
</tr>
</tbody>
</table>
</div>
</figure>
</div>
</section>
<section id="for-the-next-mentee" class="level2">
<h2 class="anchored" data-anchor-id="for-the-next-mentee">For the next mentee</h2>
<ul>
<li>Read <a href="https://docs.kernel.org/process/submitting-patches.html"><code>submitting-patches.rst</code></a> before your first patch, and the subsystem’s maintainer notes, such as <a href="https://docs.kernel.org/process/maintainer-netdev.html"><code>maintainer-netdev.rst</code></a>, before your first patch to that subsystem.</li>
<li>Look for code that is wrong, not only code that warns. Tracing a bug to the commit that introduced it, with a <code>Fixes:</code> tag, makes a patch much more useful to maintainers.</li>
<li>When a reviewer asks for more than you sent, they are usually right. Treat it as the start of a collaboration.</li>
<li>Be patient. Maintainers batch their work, and my patches waited one to two weeks.</li>
</ul>
</section>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>I am grateful to Shuah Khan for running the mentorship, and to everyone who reviewed my work: Jonathan Cameron, Andy Shevchenko, Jean-Baptiste Maneyrol, Joshua Crofts, Nuno Sá, Maxwell Doose, Tzung-Bi Shih, Simon Horman, Alex Austin, Paolo Abeni and Geert Uytterhoeven. Each of these patches is better because of them.</p>


</section>

 ]]></description>
  <category>linux-kernel</category>
  <category>lfx</category>
  <category>iio</category>
  <category>open-source</category>
  <guid>https://arnavk23.github.io/posts/2026-10-22-lfx-kernel-mentorship/</guid>
  <pubDate>Wed, 21 Oct 2026 18:30:00 GMT</pubDate>
  <media:content url="https://arnavk23.github.io/posts/2026-10-22-lfx-kernel-mentorship/do_div.png" medium="image" type="image/png" height="76" width="144"/>
</item>
</channel>
</rss>
