<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/hwmon/applesmc.c, branch linux-5.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.9.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.9.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-11-18T18:22:21Z</updated>
<entry>
<title>hwmon: (applesmc) Re-work SMC comms</title>
<updated>2020-11-18T18:22:21Z</updated>
<author>
<name>Brad Campbell</name>
</author>
<published>2020-11-12T03:08:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=88e215f9cf667d049b2fb7e53a2dd63f39b39e57'/>
<id>urn:sha1:88e215f9cf667d049b2fb7e53a2dd63f39b39e57</id>
<content type='text'>
[ Upstream commit 4d64bb4ba5ecf4831448cdb2fe16d0ae91b2b40b ]

Commit fff2d0f701e6 ("hwmon: (applesmc) avoid overlong udelay()")
introduced an issue whereby communication with the SMC became
unreliable with write errors like :

[  120.378614] applesmc: send_byte(0x00, 0x0300) fail: 0x40
[  120.378621] applesmc: LKSB: write data fail
[  120.512782] applesmc: send_byte(0x00, 0x0300) fail: 0x40
[  120.512787] applesmc: LKSB: write data fail

The original code appeared to be timing sensitive and was not reliable
with the timing changes in the aforementioned commit.

This patch re-factors the SMC communication to remove the timing
dependencies and restore function with the changes previously
committed.

Tested on : MacbookAir6,2 MacBookPro11,1 iMac12,2, MacBookAir1,1,
MacBookAir3,1

Fixes: fff2d0f701e6 ("hwmon: (applesmc) avoid overlong udelay()")
Reported-by: Andreas Kemnade &lt;andreas@kemnade.info&gt;
Tested-by: Andreas Kemnade &lt;andreas@kemnade.info&gt; # MacBookAir6,2
Acked-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Brad Campbell &lt;brad@fnarfbargle.com&gt;
Signed-off-by: Henrik Rydberg &lt;rydberg@bitmath.org&gt;
Link: https://lore.kernel.org/r/194a7d71-a781-765a-d177-c962ef296b90@fnarfbargle.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>hwmon: (applesmc) check status earlier.</title>
<updated>2020-08-21T18:32:34Z</updated>
<author>
<name>Tom Rix</name>
</author>
<published>2020-08-20T13:19:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cecf7560f00a8419396a2ed0f6e5d245ccb4feac'/>
<id>urn:sha1:cecf7560f00a8419396a2ed0f6e5d245ccb4feac</id>
<content type='text'>
clang static analysis reports this representative problem

applesmc.c:758:10: warning: 1st function call argument is an
  uninitialized value
        left = be16_to_cpu(*(__be16 *)(buffer + 6)) &gt;&gt; 2;
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

buffer is filled by the earlier call

	ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, ...

This problem is reported because a goto skips the status check.
Other similar problems use data from applesmc_read_key before checking
the status.  So move the checks to before the use.

Signed-off-by: Tom Rix &lt;trix@redhat.com&gt;
Reviewed-by: Henrik Rydberg &lt;rydberg@bitmath.org&gt;
Link: https://lore.kernel.org/r/20200820131932.10590-1-trix@redhat.com
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
</content>
</entry>
<entry>
<title>hwmon: (applesmc) avoid overlong udelay()</title>
<updated>2020-05-27T16:18:13Z</updated>
<author>
<name>Arnd Bergmann</name>
</author>
<published>2020-05-27T13:51:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fff2d0f701e6753591609739f8ab9be1c8e80ebb'/>
<id>urn:sha1:fff2d0f701e6753591609739f8ab9be1c8e80ebb</id>
<content type='text'>
Building this driver with "clang -O3" produces a link error
after the compiler partially unrolls the loop and 256ms
becomes a compile-time constant that triggers the check
in udelay():

ld.lld: error: undefined symbol: __bad_udelay
&gt;&gt;&gt; referenced by applesmc.c
&gt;&gt;&gt;               hwmon/applesmc.o:(read_smc) in archive drivers/built-in.a

I can see no reason against using a sleeping function here,
as no part of the driver runs in atomic context, so instead use
usleep_range() with a wide range and use jiffies for the
end condition.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Link: https://lore.kernel.org/r/20200527135207.1118624-1-arnd@arndb.de
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
</content>
</entry>
<entry>
<title>hwmon: (applesmc) switch to using input device polling mode</title>
<updated>2019-11-06T22:37:18Z</updated>
<author>
<name>Dmitry Torokhov</name>
</author>
<published>2019-10-02T21:43:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=58d5aa5c75ce5748a489c3b8916de9b448d954b7'/>
<id>urn:sha1:58d5aa5c75ce5748a489c3b8916de9b448d954b7</id>
<content type='text'>
Now that instances of input_dev support polling mode natively,
we no longer need to create input_polled_dev instance.

Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Link: https://lore.kernel.org/r/20191002214345.GA108728@dtor-ws
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
</content>
</entry>
<entry>
<title>treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 271</title>
<updated>2019-06-05T15:30:30Z</updated>
<author>
<name>Thomas Gleixner</name>
</author>
<published>2019-05-29T14:12:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=21eb0be9ace70fc8bccf767617ba018e02d0bb82'/>
<id>urn:sha1:21eb0be9ace70fc8bccf767617ba018e02d0bb82</id>
<content type='text'>
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license v2 as published
  by the free software foundation this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details you
  should have received a copy of the gnu general public license along
  with this program if not write to the free software foundation inc
  51 franklin street fifth floor boston ma 02110 1301 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4 file(s).

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Allison Randal &lt;allison@lohutok.net&gt;
Reviewed-by: Richard Fontana &lt;rfontana@redhat.com&gt;
Reviewed-by: Alexios Zavras &lt;alexios.zavras@intel.com&gt;
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141334.424952652@linutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>hwmon: (applesmc) Replace S_&lt;PERMS&gt; with octal values</title>
<updated>2018-12-16T23:13:39Z</updated>
<author>
<name>Guenter Roeck</name>
</author>
<published>2018-12-10T22:02:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=71ee4a400013ad187393b9cb32faee98d520516e'/>
<id>urn:sha1:71ee4a400013ad187393b9cb32faee98d520516e</id>
<content type='text'>
Replace S_&lt;PERMS&gt; with octal values.

The conversion was done automatically with coccinelle. The semantic patches
and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches/hwmon/.

This patch does not introduce functional changes. It was verified by
compiling the old and new files and comparing text and data sizes.

Cc: Henrik Rydberg &lt;rydberg@bitmath.org&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
</content>
</entry>
<entry>
<title>dmi: Mark all struct dmi_system_id instances const</title>
<updated>2017-09-14T09:59:30Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2017-09-14T09:59:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6faadbbb7f9da70ce484f98f72223c20125a1009'/>
<id>urn:sha1:6faadbbb7f9da70ce484f98f72223c20125a1009</id>
<content type='text'>
... and __initconst if applicable.

Based on similar work for an older kernel in the Grsecurity patch.

[JD: fix toshiba-wmi build]
[JD: add htcpen]
[JD: move __initconst where checkscript wants it]

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Jean Delvare &lt;jdelvare@suse.de&gt;
</content>
</entry>
<entry>
<title>hwmon: (applesmc) Avoid buffer overruns</title>
<updated>2017-07-15T23:38:56Z</updated>
<author>
<name>Guenter Roeck</name>
</author>
<published>2017-07-12T03:53:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1009ccdc64ee2c8451f76b548589f6b989d13412'/>
<id>urn:sha1:1009ccdc64ee2c8451f76b548589f6b989d13412</id>
<content type='text'>
gcc 7.1 complains that the driver uses sprintf() and thus does not validate
the length of output buffers.

drivers/hwmon/applesmc.c: In function 'applesmc_show_fan_position':
drivers/hwmon/applesmc.c:82:21: warning:
	'%d' directive writing between 1 and 5 bytes into a region of size 4

Fix the problem by using scnprintf() instead of sprintf() throughout the
driver. Also explicitly limit the number of supported fans to avoid actual
buffer overruns and thus invalid keys.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
</content>
</entry>
<entry>
<title>hwmon : (applesmc) Fix uninitialized variables warnings</title>
<updated>2015-11-16T05:52:39Z</updated>
<author>
<name>Shuah Khan</name>
</author>
<published>2015-11-05T22:39:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5e0a0ee4d397665e5a509ed03ed9c41727c5f228'/>
<id>urn:sha1:5e0a0ee4d397665e5a509ed03ed9c41727c5f228</id>
<content type='text'>
Fix the following "maybe used uninitialized" warnings by
initializing the variables to keep the compiler quiet.
There is no "used uninitialized" in this case.

  CC [M]  drivers/hwmon/applesmc.o
drivers/hwmon/applesmc.c: In function ‘applesmc_init_smcreg’:
drivers/hwmon/applesmc.c:595:43: warning: ‘right_light_sensor’
may be used uninitialized in this function [-Wmaybe-uninitialized]
  s-&gt;num_light_sensors = left_light_sensor + right_light_sensor;
                                           ^
drivers/hwmon/applesmc.c:540:26: note: ‘right_light_sensor’ was
declared here
  bool left_light_sensor, right_light_sensor;
                          ^
drivers/hwmon/applesmc.c:595:43: warning: ‘left_light_sensor’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
  s-&gt;num_light_sensors = left_light_sensor + right_light_sensor;
                                           ^
drivers/hwmon/applesmc.c:540:7: note: ‘left_light_sensor’ was
declared here
  bool left_light_sensor, right_light_sensor;
       ^

Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
</content>
</entry>
<entry>
<title>hwmon: applesmc: fix comment typos</title>
<updated>2015-09-29T13:28:01Z</updated>
<author>
<name>Bastien Nocera</name>
</author>
<published>2015-09-10T12:46:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0c6cac7ab44435d8837931a561cc4d58530cc032'/>
<id>urn:sha1:0c6cac7ab44435d8837931a561cc4d58530cc032</id>
<content type='text'>
s/ressources/resources/

Signed-off-by: Bastien Nocera &lt;hadess@hadess.net&gt;
Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
</feed>
