CINXE.COM
LKML: Jean Delvare: Re: [PATCH] ds1337 4/4
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Jean Delvare: Re: [PATCH] ds1337 4/4</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Jean Delvare" href="/groupie.php?aid=8305" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/4"> [Apr]</a> 聽 <a class="nb" href="/lkml/2005/4/10"> [10]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/4/10/143" onclick="this.href='/lkml/headers'+'/2005/4/10/143';">[headers]</a>聽 <a href="/lkml/bounce/2005/4/10/143">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/3/31/279">First message in thread</a></li><li><a href="/lkml/2005/4/8/206">James Chapman</a><ul><li><a href="/lkml/2005/4/10/130">Ladislav Michl</a><ul><li class="origin"><a href="/lkml/2005/4/12/352">Jean Delvare</a><ul><li><a href="/lkml/2005/4/12/352">James Chapman</a><ul><li><a href="/lkml/2005/4/13/66">Ladislav Michl</a></li></ul></li></ul></li></ul></li></ul></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Sun, 10 Apr 2005 23:10:06 +0200</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Jean Delvare <></td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [PATCH] ds1337 4/4</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">Hi Ladislav,<br /><br />> Driver has no chance to know about hardware design.<br /><br />If you want the driver to somehow interact with the battery charging<br />register, it will have to. We just can't let the user write random value<br />to this register.<br /><br />> Based on your and Jean's input, following so far sounds reasonable:<br />> Create "charge" sysfs entry for ds1339 when it is detected. Do not<br />> write any value to Trickle Charge register, until its value is written<br />> to this entry.<br /><br />While I admit I had this in mind in the first place, the more I think of<br />it and the less I like it. It's slightly better than changing the<br />charging rate right when loading the driver, but that's still dangerous.<br />Users could write a value which doesn't match the hardware design, and<br />bad things could happen.<br /><br />> Agree, but with probability near the certainty I can tell that device<br />> works a bit differently than described in datasheet. Anyway, new 100%<br />> reliable test is done, so it could be eventually used if ds1339<br />> support finds its way into driver.<br /><br />"100% realiable" here means that it works for you, which isn't enough.<br />At least James would have to check how it works with his DS1337, and<br />there might be other revisions of both chips which behave differently.<br />There might be other mostly-compatible chips in the game too.<br /><br />> > > Eh? Register is 8bit, that's 256 combinations.<br />> > <br />> > Reserved bits have fixed values that you can test for.<br />> <br />> Think about this register as about NVRAM address. It can have any<br />> value, but only certain values will enable charge.<br /><br />Most of which nobody has any interest in writing. Some I2C devices are<br />hard to detect and the DS1337/DS1339 are of these. We use the tricks we<br />find. Sure, a strict check on this register might miss a DS1339, but<br />that's better than detecting a different chip as a DS1339.<br /><br />> How are you using this driver? There is non-static function<br />> ds1337_do_command which expects id. How do you know which id belongs<br />> to which chip?<br /><br />I second this question, as it stroke me too. This function doesn't sound<br />exactly usable to me. Identifying the device by bus and address would<br />make more sense than an arbitrary id you have no way to learn about.<br /><br />> Do you actually have machine with more than one ds1337?<br />> Chip has fixed address, so only one can hang on one bus (am I right?)<br /><br />You are.<br /><br />> PS. I'm sorry about some formulations I used in earlier mails. I was<br />> overworked and tired and that affected my otherwise (hopefully) good<br />> decorum :)<br /><br />I'm really happy to read this :) You are of course forgiven. We all have<br />bad days.<br /><br />Back to the issue, some random thoughts summarizing my opinion:<br /><br />1* Initializing the battery charge register is a firmware/bios issue, as<br />you underlined earlier. It would make sense (and would be easier) to<br />just ignore it at the driver level.<br /><br />2* If it makes sense to stop the charge, then we should provide a simple<br />*switch* to the user, from the default charging register value (as<br />previously set by the firmware/bios) to 0 and back. The switch would<br />probably be a sysfs file unless a different API already exists.<br /><br />3* Having the driver write an arbitrary non-0 value to the register<br />should not be done unless the system has been identified. I have no idea<br />how your system can be identified (DMI?), but if it can't, then I'd<br />better see the register ignored altogether.<br /><br />4* Remember that you can always write a simple C tool relying on the<br />i2c-dev interface to do the job. The advantage of this approach is that<br />you can put big fat warnings and request user confirmation before any<br />action.<br /><br />Hope that helps,<br />-- <br />Jean Delvare<br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo@vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-04-10 23:13 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>