linux/drivers/char/tile-srom.c
<<
>>
Prefs
   1/*
   2 * Copyright 2011 Tilera Corporation. All Rights Reserved.
   3 *
   4 *   This program is free software; you can redistribute it and/or
   5 *   modify it under the terms of the GNU General Public License
   6 *   as published by the Free Software Foundation, version 2.
   7 *
   8 *   This program is distributed in the hope that it will be useful, but
   9 *   WITHOUT ANY WARRANTY; without even the implied warranty of
  10 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11 *   NON INFRINGEMENT.  See the GNU General Public License for
  12 *   more details.
  13 *
  14 * SPI Flash ROM driver
  15 *
  16 * This source code is derived from code provided in "Linux Device
  17 * Drivers, Third Edition", by Jonathan Corbet, Alessandro Rubini, and
  18 * Greg Kroah-Hartman, published by O'Reilly Media, Inc.
  19 */
  20
  21#include <linux/module.h>
  22#include <linux/moduleparam.h>
  23#include <linux/init.h>
  24#include <linux/kernel.h>       /* printk() */
  25#include <linux/slab.h>         /* kmalloc() */
  26#include <linux/fs.h>           /* everything... */
  27#include <linux/errno.h>        /* error codes */
  28#include <linux/types.h>        /* size_t */
  29#include <linux/proc_fs.h>
  30#include <linux/fcntl.h>        /* O_ACCMODE */
  31#include <linux/aio.h>
  32#include <linux/pagemap.h>
  33#include <linux/hugetlb.h>
  34#include <linux/uaccess.h>
  35#include <linux/platform_device.h>
  36#include <hv/hypervisor.h>
  37#include <linux/ioctl.h>
  38#include <linux/cdev.h>
  39#include <linux/delay.h>
  40#include <hv/drv_srom_intf.h>
  41
  42/*
  43 * Size of our hypervisor I/O requests.  We break up large transfers
  44 * so that we don't spend large uninterrupted spans of time in the
  45 * hypervisor.  Erasing an SROM sector takes a significant fraction of
  46 * a second, so if we allowed the user to, say, do one I/O to write the
  47 * entire ROM, we'd get soft lockup timeouts, or worse.
  48 */
  49#define SROM_CHUNK_SIZE ((size_t)4096)
  50
  51/*
  52 * When hypervisor is busy (e.g. erasing), poll the status periodically.
  53 */
  54
  55/*
  56 * Interval to poll the state in msec
  57 */
  58#define SROM_WAIT_TRY_INTERVAL 20
  59
  60/*
  61 * Maximum times to poll the state
  62 */
  63#define SROM_MAX_WAIT_TRY_TIMES 1000
  64
  65struct srom_dev {
  66        int hv_devhdl;                  /* Handle for hypervisor device */
  67        u32 total_size;                 /* Size of this device */
  68        u32 sector_size;                /* Size of a sector */
  69        u32 page_size;                  /* Size of a page */
  70        struct mutex lock;              /* Allow only one accessor at a time */
  71};
  72
  73static int srom_major;                  /* Dynamic major by default */
  74module_param(srom_major, int, 0);
  75MODULE_AUTHOR("Tilera Corporation");
  76MODULE_LICENSE("GPL");
  77
  78static int srom_devs;                   /* Number of SROM partitions */
  79static struct cdev srom_cdev;
  80static struct class *srom_class;
  81static struct srom_dev *srom_devices;
  82
  83/*
  84 * Handle calling the hypervisor and managing EAGAIN/EBUSY.
  85 */
  86
  87static ssize_t _srom_read(int hv_devhdl, void *buf,
  88                          loff_t off, size_t count)
  89{
  90        int retval, retries = SROM_MAX_WAIT_TRY_TIMES;
  91        for (;;) {
  92                retval = hv_dev_pread(hv_devhdl, 0, (HV_VirtAddr)buf,
  93                                      count, off);
  94                if (retval >= 0)
  95                        return retval;
  96                if (retval == HV_EAGAIN)
  97                        continue;
  98                if (retval == HV_EBUSY && --retries > 0) {
  99                        msleep(SROM_WAIT_TRY_INTERVAL);
 100                        continue;
 101                }
 102                pr_err("_srom_read: error %d\n", retval);
 103                return -EIO;
 104        }
 105}
 106
 107static ssize_t _srom_write(int hv_devhdl, const void *buf,
 108                           loff_t off, size_t count)
 109{
 110        int retval, retries = SROM_MAX_WAIT_TRY_TIMES;
 111        for (;;) {
 112                retval = hv_dev_pwrite(hv_devhdl, 0, (HV_VirtAddr)buf,
 113                                       count, off);
 114                if (retval >= 0)
 115                        return retval;
 116                if (retval == HV_EAGAIN)
 117                        continue;
 118                if (retval == HV_EBUSY && --retries > 0) {
 119                        msleep(SROM_WAIT_TRY_INTERVAL);
 120                        continue;
 121                }
 122                pr_err("_srom_write: error %d\n", retval);
 123                return -EIO;
 124        }
 125}
 126
 127/**
 128 * srom_open() - Device open routine.
 129 * @inode: Inode for this device.
 130 * @filp: File for this specific open of the device.
 131 *
 132 * Returns zero, or an error code.
 133 */
 134static int srom_open(struct inode *inode, struct file *filp)
 135{
 >
 135{
pr_err(&quoivate_datae" clasass="="sref">srom_devices;
&qumilelINTERVAL" class="sreuct   37#include <0c#L124" id="L124" class="line" name="L728"> 128#include <  39#include <  40#include <  41
 1321/*
  431 * Si1e of our hypervisor I/O requestan>
  441 * so1that we don't spend large u of the device.
  451 * hy1ervisor.  Erasing an SROM sect-srom.c#L131" id="L131" class="line" name="L536"> >
1 * a 1econd, so if we allowed the usepan>
  471 * en1ire ROM, we'd get soft loce-srom.c#L134" id="L134" class="line" name="L8">  481 */srom_devs; releasea href="drivers/charreleaseclass="sref">inode *inode, struct file *filp)
  49#define   50
mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_devivers/char/tile-srom.c#L119" ids">pr_err(&quoivate_datae" cc#L124" id="L124" class="line" name="L1">  511/*hv_devdummyass="string">&qdummye" cc#L124" id="L124" class="line" name="L132"> 1321 * Wh15rom.c#L83" id="L83" class="line" name="L813">  531 */anrs/cha/chart  54
msleep(srom_deviceef="+code=srom_devie" c" ids">pr_err(  551/*retval ==viceef="+code=srom_devie" c" ids">pr_err(, 0, (  561 * In15+code=retval" class=""sref">_srom_write(int retval ==viceef="+code=srom_devie" c" ids">pr_err(, 0, (srom_dedummyass="string">&qdummye" cef">retval);
ef="dFLUSH_OFFVAL);
  471 */u32 srom_deviceef="+code=srom_devie" c" ids">pr_err(  48#define   49
u32 pr_err(&quoivate_datae" clas">pr_err();
  601/*  611 * Ma16ivers/char/ti"sref">0c#L124" id="L124" class="line" name="L2">  621 */
  63#define   54
  65struct   16> ** In16cond, so if we allowed the usepan>,   67        
  68          49        10">  70        struct 10">  61};
  72
  73static int   74srom_deva href="+code=_srom_write" class="sref">_srom_wr(int file *filp)
hv_dev__the< filp)
  75size_t count)
retval);
 href="+code=off" class="sref">o>filp)
  76  17> *u32"17lass="sref">usref">retval,   78static int buf,
  79static struct u="sref">mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_devivers/char/tile-srom.c#L119" ids">pr_err(&quoivate_datae" cc#L124" id="L124" class="line" name="L0">  80static struct   81static struct ,
hv_devrs/charrivers/char/til=s/charINTERVAL" class="sref">SRK_SIZE ((retval);
GFP_KERNERVAL);
  82
,
  831/*EIO;
  741 * Ha18rom.c#L65" id="L65" class="line" name="L615">  851 */retval == s="s_    _span>
srom_deviceef="+code=srom_devie" c" ids">pr_err(  86
_srom_wra href="+code=retries" class="slasEIO;
;
S="drivers/char/til="co="de" cc#L13char/til="co="de" cc#L124" id="L124wads18 * Gre17+cof="+code=loff_t" classref">retval;
{
1u="sr26" id="L126" class="line" name="L3">  90  1      int   91  1      for (;;) {
S="drivers/char/tile-srom.c#L10119" id="L119" class="line" name="L6">  92  1              reref">hv_devhdl, coef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L116" 93  1                        1     1      hv_devhdl,ssfea_n>
<_paef="drivers/char/ssfea_n>
<_paeflass="sref">hv_devrs/cmia href="+code=inmiaRVAL" class="sref">S="drivers/char/tile-srom.ef">retval);
 hreRK_SIZE ((3char/til="co="de" cc#L124" id="L124wad 94  1              if (  95  1                      re1turn 1a href="+code=retval" >hv_devhdl, coef="drivers/char/tile coef="drc#L1="sref">hv_devrs/c>(int pr_err(, 0, (S="drivers/char/til="co="de" cc#L113" id="L113" class="line" name="L5">  96  1              if (Sssfea_n>
<_paef="drivers/char/ssfea_n>
<_paeflass3char/til="co="de" cc#L124" id="L124wad pan>);
retval == s=" coef="drivers/char/tile coef="drc#L1=h" c=c#L119" id="L119" class="line" name="L119" 98  1              if (retval == s="href="+code=HV_EBUSY" class="sref">115" id="L115" class="line" name="L6">  99  1                      msretval" >hv_devhdl,ref="+code=hv_dev_pwrite" class="sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162> 1002                       c2ntinu2;
2> 1032               return -<2 href2"+code=EIO" class="sre">retval == s="copy_to<  ==viceivers/char/tile-srom.c#L11= class="sref">S="drivers/char/til="co="de" cc#L11sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L1) !=c#L119" id="L119" class="line" name="L1192> 1042       }
hv_devhdl,ref="+code=hv_dev_pwrite" class="s/a>;
;
sf="dr16" id="L116" class="line" name="L1162>26#in 2> 1082                        2 hv_devhdl,ref="+code=hv_dev_pwrite" class=+"sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162>29#in
hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162> 1102       int  ==viceivers/char/tile-srom.c#L1=+"sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162>21#incclude <S="drivers/char/tile-srom.ef"> -"sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162> 1022               2> 1142               if (msleep(srom_deviceef="+code=srom_devie" c" ids">pr_err(2> 1152                       r2turn 2a href="+code=a>,
S="drivers/char/til="co="de" cc#L13char/til="co="de" cc#L124" id="L124wa2> 1162               if (0c#Ltval;
2> 1192                       <2 href21c#L60" id="L60" class="line" name="L610">2> 1202                       c2ntinu22a href="drivers/char/tile-sroom.c#L132" id="L132" class="line" name="L2">2> 1212               }
evhdl" claeR2> 1222               2> 1232               return -<2 href22our hypervisor I/O requestan>
< Userr wors data buffere-srom.c#L131" id="L131" class="line" name="L8">2> 1242       }
10">2> 1252
10">2> 126210">2> 1172span class="comment">/**2/span2
2> 1282span class="comment"> * 2rom_o2en() - Device open routine.2> 1292span class="comment"> * 2inode22" class="sreef">srom_deva href="+code=_srom_write" class="sref">_srom_wr(int t ref">file *filp)
hv_dev__the< filp)
2> 1302span class="comment"> * 2filp:23
count)
retval);
 href="+code=off" class="sref">o>filp)
2> 1312span class="comment"> *<2span>2 * 2eturn23_err" clasref!>retval, 2> 1332span class="comment"> */2/span23+code=EIO" cl>buf,
2> 1342tatic int msef">mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_devivers/char/tile-srom.c#L119" ids">pr_err(&quoivate_datae" cc#L124" id="L124" class="line" name="L0">2> 1352
2> 1262 class="line" name="L1352> 1352/a>{
hv_devrs/charrivers/char/til=s/charINTERVAL" class="sref">SRK_SIZE ((retval);
GFP_KERNERVAL);
2 37#2nclude <,
2> 128#2nclude <re/a>;
2 39#2nclude <2 40#2nclude < == s="s_    _span>
srom_deviceef="+code=srom_devie" c" ids">pr_err(2 41
2a href="drivers/char1/ti2e14n>24s/char/tile-srom.c#L1 class="sref">Sef="+code=retries" class="slasEIO;
;
1/*<2s1an>24_err" class="sref">pr_err(S="drivers/char/til="co="de" cc#L13char/til="co="de" cc#L124" id="L124wa2 43<2pan class="comment">1 * 2i1e o24+code=EIO" class="sref">EIO;
1 * 2o1tha24ile-srom.c#L125" id="L125" class="line" name="L1252 45<2pan class="comment">1 * 2y1erv24.c#L14" id="L124" class="line" name="L0">2> >
<2pan class="comment">1 * 2 1eco24a>{
S="drivers/char/tile-srom.c#L10119" id="L119" class="line" name="L6">2 47<2pan class="comment">1 * 2n1ire24
hv_devhdl, coef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162 48<2pan class="comment">1 */2/14m_24e=retval" class="sref"ef">hv_devhdl,ssfea_n>
<_paef="drivers/char/ssfea_n>
<_paeflass="sref">hv_devrs/cmia href="+code=inmiaRVAL" class="sref">S="drivers/char/tile-srom.ef">retval);
 hreRK_SIZE ((3char/til="co="de" cc#L124" id="L124w/2/39#2efine 2 50
2a href="drivers/char1/ti2e15=m25
retval == s="copy_cs/c< S="drivers/char/til="co="de" cc#L1s= class="sref">Ssvers/char/tile-srom.c#L11= class="sref">Sssfea_n>
<_paef="drivers/char/ssfea_n>
<_paeflass3 !=c#L119" id="L119" class="line" name="L1192 51<2pan class="comment">1/*<2s15iv25s/char/tile-srom.c#L1rom.c#L1 class="sref">Sef="+code=retries" class="slasEIO;
;
1 * 2h15ro25_err" class="sref">prrrrrrrrrf="dr16" id="L116" class="line" name="L1162 53<2pan class="comment">1 */2/15ef25+code=EIO" class="sre25" id="L125" class="line" name="L1252 54
2a href="drivers/char1/ti2e15ar25c#L65" id="L65" class="line" name="L615">2 55<2pan class="comment">1/*<2s15n 25 href="+code=retval" >hv_devhdl, coef="drivers/char/tile coef="drc#L1="sref">hv_devrs/c>(int t retval ==viceef="+code=srom_devie" c" ids">pr_err(, 0, (S="drivers/char/til="co="de" cc#L1s" id="L65" class="line" name="L615">2  >
<2pan class="comment">1 * 2n15+c2de=retval" class=""sreeeeeeeeeeeeeeeeeeeeeeeeep)
Sssfea_n>
<_paef="drivers/char/ssfea_n>
<_paeflass3char/til="co="de" cc#L124" id="L124wa2 47<2pan class="comment">1 */2/15la25
retval == s=" coef="drivers/char/tile coef="drc#L1=h" c=c#L119" id="L119" class="line" name="L1192 48#2efine retval == s="href="+code=HV_EBUSY" class="sref">115" id="L115" class="line" name="L6">2 49
2a href="drivers/char1/ti2e15la25+code=msleep" class="sref">msretval" >hv_devhdl,ref="+code=hv_dev_pwrite" class="sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162 60<2pan class="comment">1/*<2s16ro26
1 * 2a16iv26s/char/tile-srom.c#L102" id="L102" class="line" name="L1022 62<2pan class="comment">1 */2/1pan26c#L83" id="L83" class="line" name="L813">2 63#2efine hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162 54
2a href="drivers/char1/ti2e1sro26e=retval" class="srefp)
hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162 65s2ruct hv_devhdl,ivers/char/tile-srom.c#L1=+"sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162 16><2pan class="comment"> ** 2n16co26e=retval" class=""sref">_srom_wra hr="drivers/char/tile-srom.ef"> -"sref">hv_dev_pwriteef="drivers/char/tile coef="drc#L116" id="L116" class="line" name="L1162 67 2      2 49 2      u32 srom_deviceef="+code=srom_devie" c" ids">pr_err(2 70 2      struct u32 S="drivers/char/til="co="de" cc#L13char/til="co="de" cc#L124" id="L124wa2 61}2
EIO;
2 75<2 href="+code=MODULE_1AUT2O17n 27a href="drivers/char/tilee-sr Provide our own impletileae-sr so wEAGAn  evhds">prtotal_="sr-srom.c#L27" id="L27" class="line" name="L214">2 76<2 href="+code=MODULE_1LIC2N1E" 2lac#L1tval);
 href="+code=off" class="sref">o>filex  *ref">file *filp)
firetval);
 href="+code=off" class="sref">o>filtval);
 hrerefseode=off" class="refseo">fire"ef">hv_devhdl,origia href="+code=inorigiac#L135" id="L135" class="line" name="L3">2 17><2pan class="comment"> *u32"17la2s="sre19" id="L119" class="line" name="L1192 78s2atic int mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_devivers/cde=filp" class="sref">fis">pr_err(&quoivate_datae" cc#L124" id="L124" class="line" name="L0">2 79s2atic struct u="srf">EIO;
Sdride=filp" class="sref">firetval);
 hrerefseode=off" class="refseo">fire>hv_devhdl,origia href="+code=inorigiac#L1size_t pr_err(srom_deva href="+code=_srom_write" class="sref">_srom_wrtotal_=how+code=srom_devitotal_=hows">ref">file *srom_devicef="+code=srom_deviclass="s" id="L65" class="line" name="L615">2 83<2pan class="comment">1/*<2s18ef2"+code=EIO" class="sreeeeeeeeeeef">file *srom_deviceattrhref="+code=hv_attrc#L1siss="sp)
2 74<2pan class="comment">1 * 2a18ro2.c#L6519" id="L119" class="line" name="L1192 85<2pan class="comment">1 */2/18n 2a href="+csrefef">mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_deviverl" cget_drvass="string">&quoivl" cget_drvass=RVAL" class="sref">Sf="+code=srom_deviclass="3char/til="co="de" cc#L124" id="L124wa2 76<2a href="drivers/char1/ti2e18+c2de=retval" claf">EIO;
Ssvers/char/tile-srom.c#L11=  error %d\n"retval);
pr_err( * G2e17+c28T#L123" id="L123" class="line" name="L5">2 89{
2srom_deva href="+code=_srom_write" class="sref">_srom_wr(ector_=how+code=srom_devi(ector_=hows">ref">file *srom_devicef="+code=srom_deviclass="s" id="L65" class="line" name="L615">2 90  2      int file *srom_deviceattrhref="+code=hv_attrc#L1siss="sp)
2 91  2      for (;;) {
mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_deviverl" cget_drvass="string">&quoivl" cget_drvass=RVAL" class="sref">Sf="+code=srom_deviclass="3char/til="co="de" cc#L124" id="L124wa2 93  2                        2     2      EIO;
Ssvers/char/tile-srom.c#L11=  error %d\n"retval);
pr_err(2 96  2              if (srom_deva href="+code=_srom_write" class="sref">_srom_wrpage_=how+code=srom_devipage_=hows">ref">file *srom_devicef="+code=srom_deviclass="s" id="L65" class="line" name="L615">2 17><2                      co2ntinu2;
file *srom_deviceattrhref="+code=hv_attrc#L1siss="sp)
2 78s2              if (u="sref">mutex  *srom_deviceef="+code=srom_devie" class="sref">hv_deviverl" cget_drvass="string">&quoivl" cget_drvass=RVAL" class="sref">Sf="+code=srom_deviclass="3char/til="co="de" cc#L124" id="L124wa3> 1003                       c3ntinu3;
EIO;
Ssvers/char/tile-srom.c#L11=  error %d\n"retval);
pr_err(3> 1033               return -<3 href3"+codess="sref">file *msleep(Stotal_="sr+code=srom_devitotal_="src#L1retval);
 hreR_IRUGers/char/tile-srR_IRUGec#L1retval);
 hretotal_=how+code=srom_devitotal_=hows">rretval);
 hreVAL);
3>51043                      re3le-sr30 href="+code=leep(S(ector_="sr+code=srom_devi(ector_="srss="retval);
 hreR_IRUGers/char/tile-srR_IRUGec#L1retval);
 hre(ector_=how+code=srom_devi(ector_=hows">rretval);
 hreVAL);
3>61043              if ((Spage_="sr+code=srom_devipage_="srss="retval);
 hreR_IRUGers/char/tile-srR_IRUGec#L1retval);
 hrepage_=how+code=srom_devipage_=hows">rretval);
 hreVAL);
3>71043                      co3e_t" 30="sref">u32 );
3>81043              if (3> 1103       int ref">file *srom_devicef="+code=srom_deviclass="se *srom_devicem href="+code=file"m hrs">r35" id="L135" class="line" name="L3">3>21#i3cclude <srom_devicem href="+code=file"m hrs">r="sref">hv_deviverR_IRUGers/char/tile-srR_IRUGec#L1 |sref">hv_deviverR_IWUSRef="drivers/chaR_IWUSRc#L124" id="L124" class="line" name="L0">3> 1133                        3     31     EIO;
SKERNERVAL);
retval);
&quoivl" c    RVAL" class="sref">Sf="+code=srom_deviclass="33char/til="co="de" cc#L124" id="L124wa3> 1143               if (3> 1163               if (10">3> 1173                       c3ntinu3110">3>81043               if (3> 1193                       <3 href31" class="sressref"f">file *  *r="s19" id="L119" class="line" name="L1193> 1203                       c3ntinu32
r="s32 3> 1213               }
rs" id="L65" class="line" name="L615">3> 1023               hv_devhdl,  *3> 1133               return -<3 href323r="s32 rs" id="L65" class="line" name="L615">3> 1143       }
hv_devhdl,opea href="+code=inopeass="="s32  *rs" id="L65" class="line" name="L615">3> 1153
hv_devhdl,3> 1163/**3/span32c#L78" id="L78" class="line" name="L78"> 3> 1283span class="comment"> * 3rom_o3en() - Device open routine.3> 1293span class="comment"> * 3inode32Inode for this device.Ep_minoreR10">3> 1303span class="comment"> * 3filp:33ile for this specific open o_poL3">: Per-ile-sr ize_ ss="rom.c#L133" id="L133" class="line" name="L3">3> 1313span class="comment"> *<3span>33times to poll the state@index: Dle-sr to s"> upom.c#L133" id="L133" class="line" name="L3">3> 1023span class="comment"> * 3eturn33zero, or an error code.3> 1333span class="comment"> */3/span33+codess="sre"ef">hv_devhdl,rreles">Ep_minoref="drivers/charreles">Ep_minors">ref">file *srom_deviceef="+code=srom_devie" classre"ef">hv_devhdl,index+code=srom_deviindexs">r35" id="L135" class="line" name="L3">3> 1343tatic int mutex  *srom_devicef="+code=srom_deviclass="char/til="co="de" cc#L124" id="L124wa3> 1263 class="line" name="L1353> 1353/a>{
hv_devhdl, (hv_deviverff="+code=srom_devie" c" ids">pr_err( 3> 128#3nclude <srom_devicem_un  initef="+code=file"m_un  inits">re"="sref">srom_deviceef="+code=srom_devie" c" ids">pr_err(3 39#3nclude <3 40#3nclude < == s=">(int srom_dedummff="+code=srom_devie" c" ids">pr_err(3 41
3a href="drivers/char1/ti3e14n>34s/char/tile-srom.c#L1e=loff_ef">srom_deviceize_tTOTALss="s_OFFef="drivers/chaRze_tTOTALss="s_OFFle-ss=="srofetval ==viceef="+code=srom_devie" c" ids">pr_err(,total_="sr+code=srom_devitotal_="src#L13)=h" c>115" id="L115" class="line" name="L6">3> 132<3pan class="comment">1/*<3s1an>34_err" class="sref">prref">re/a>;
1 * 3i1e o34+code=EIO" cl!uf == s=">(int srom_dedummff="+code=srom_devie" c" ids">pr_err(1 * 3o1tha34e=retval" class="srefe=loff_ef">srom_deviceize_tSECTORss="s_OFFef="drivers/chaRze_tSECTORss="s_OFFle-ss=="srofetval ==viceef="+code=srom_devie" c" ids">pr_err(,(ector_="sr+code=srom_devi(ector_="srss="3)=h" c>115" id="L115" class="line" name="L6">3> 1353pan class="comment">1 * 3y1erv34 href="+code=retval" ref">re/a>;
1 * 3 1eco34a>{
 == s=">(int srom_dedummff="+code=srom_devie" c" ids">pr_err(1 * 3n1ire34
srom_deviceize_tPAGEss="s_OFFef="drivers/chaRze_tPAGEss="s_OFFle-ss=="srofetval ==viceef="+code=srom_devie" c" ids">pr_err(,page_="sr+code=srom_devipage_="srss="3)=h" c>115" id="L115" class="line" name="L6">3> 128#3pan class="comment">1 */3/14m_34e=retval" class="srefref">re/a>;
3 50
3a href="drivers/char1/ti3e15=m350"sref">u32 hv_deviverl" -sr_c cla href="+code=hv_ile-sr_c cla RVAL" class="sref">S(hdl"ef="++code=srom_devices" ode=sle-ss="="sref">srom_dedummplatform_bu++code=srom_deviplatform_bu+ss="rhar/til="co="de" cc#L124" id="L124wa3 51<3pan class="comment">1/*<3s15iv35s/char/tile-srom.c#L1rom.c#L132 S(hdl"majoref="drivers/charrelemajorss="se *r3retval);
retval);
r3char/til="co="de" cc#L124" id="L124wa3> 132<3pan class="comment">1 * 3h15ro35_err" class="f">EIO;
;
Sf="+code=srom_deviclass="3char/til="co="de" cc#L124" id="L124wa3>43<3pan class="comment">1 */3/15ef353 55<3pan class="comment">1/*<3s15n 35a href="drivers/char/tilee-srs=rreleiniteR3  >
<3pan class="comment">1 * 3n15+c35e=retss="sre"ef">hv_devhdl,rreleinitef="+code=file"rreleinitRVAL">buf15" id="L115" class="line" name="L6">3 47<3pan class="comment">1 */3/15la35="sre19" id="L119" class="line" name="L1193 48#3efine retval, u32 hv_deviverMKDEV+code=srom_deviMKDEVRVAL" class="sref">S(hdl"majoref="drivers/charrelemajorss="se03char/til="co="de" cc#L124" id="L124wa3 60<3pan class="comment">1/*<3s16ro36c#L51" id="L51" class="line" name="L511">3 61<3pan class="comment">1 * 3a16iv36s/char/tile-sif we allowed the usep/nm.c#L3" id="L3" class="line" name="L3">10">3 62<3pan class="comment">1 */3/1pan36zero, or an error code.10">3 43<3efine 3 54
3a href="drivers/char1/ti3e1sro36we don't spend large u oaaaaaaaa*om.c#L27" id="L27" class="line" name="L214">3 65s3ruct (hv_deviverkzrrivers/char/til=s/chzrINTERVAL"4ss=r"srofef">file *3 16><3pan class="comment"> ** 3n16co36c#L127" id="L127" class="line" name="L1273 67 3      3 48#3      Si+code=srom_devii,sasc#L12 ;e *hv_devhdl, (3 70 3      struct 3 61<3
file *srom_devicenew_ces" cla-srref="drivers/chanew_ces" cla-srr,sasc#3" id="L123" class="line" name="L2">3 62<3a href="drivers/char1/ti3e17rn37_err" class="sref">prrrrrrrrrref">hv_deviverk clINTErs/char/til=s/ch clINTERVAL" class="sref">S(hdl"cla-srref="drivers/char/tile-s-srrss=",a" class="sref">Si+code=srom_devii,sas+1)ss=r"srofef">file *3 43<3atic int hv_deviverKERNERVAL);
hv_deviver__KERNZERers/char/tile-sr__KERNZERe.c#L123" id="L123" class="line" name="L2">3 74<3 href="+code=module_1par3m17m_37e=retval" class="sref!uf,
stval, 3 76<3 href="+code=MODULE_1LIC3N1E" 37e=retval" class=""sreeeeeeeeegotoe *3 67 3pan class="comment"> *u33"17la37
hv_devhdl,ces" cla-srref="drivers/char/tile-s-srrss="="sref">hv_devivernew_ces" cla-srref="drivers/chanew_ces" cla-srr,sas24" id="L124" class="line" name="L0">3 49 3atic struct Ssvers/char/tile-srom.c#L11=  error %d\n"retval);
3 80s3atic struct hv_deviverirtAddeopea href="+code=inirtAddeopeaRVAL"" class="sref">SHV_VirtAddref="drivers/chaHV_VirtAddr,sas1 class="sref">Ssvers/char/tile-srom.c#L11=03char/til="co="de" cc#L124" id="L124wa3 81s3atic struct  == s=" (11119" id="L119" class="line" name="L1193 82
3a href="drivers/char1/ti3e18e=38_err" class="sref">prrrrrrrrr!uf == s=" (hv_deviverHV_EMeDEV+code=srom_deviHV_EMeDEV,sas19" id="L119" class="line" name="L1193 43<3pan class="comment">1/*<3s18ef3"+code=EIO" class="sreeeeeeeeeeers/chatval ==vicepr_not-sr+code=srom_devipr_not-srRVAL"  error %d\n"r9" id="L119" class="line" name="L1193 74<3pan class="comment">1 * 3a18ro38e=retval" class="srefe=loff_sreeeeeeeeeeers/chatval ==vicei+code=srom_devii,sasretval);
1 */3/18n 38 href="+code=retval" clasf">sf="dr16" id="L116" class="line" name="L1163 76<3a href="drivers/char1/ti3e18+c38e=retval" class=""sre02" id="L102" class="line" name="L1023 17><3 href="drivers/char/tile3e_t" 38
 ==vicei+code=srom_devii,sas].>hv_devhdl, 0, (hv_deviverl" a href="+code=HV_VAddr" le-s23" id="L123" class="line" name="L2">3 78s3aan class="comment"> * G3e17+c38f="+code=loff02" id="L102" class="line" name="L1023 49 3u32 hv_deviveri+code=srom_devii,saschar/til="co="de" cc#L124" id="L124wa3 90  3      int 3 91  3      for (;;) {
3 92  3              ;
3 95  3                      re3turn 395="+code=loff02" id="L102" class="line" name="L1023 96  3              if (3 78s3              if (hv_devhdl,registf=_chrAdderegioa href="+code=inregistf=_chrAdderegioaRVAL" class="sref">Sf="+code=srom_deviclass="retval);
3char/til="co="de" cc#L124" id="L124wa4> 1004                       c4ntinu4;
Sefsultef="+code=file"efsultss="IO<>hv_devhdl,lINTE_chrAdderegioa href="+code=inlINTE_chrAdderegioaRVAL""="sref">srom_dedummf="+code=srom_deviclass="re0retval);
3char/til="co="de" cc#L124" id="L124wa4>21004              pr_err(hv_deviverMAJORef="drivers/chaMAJORRVAL" class="sref">Sf="+code=srom_deviclass="3char/til="co="de" cc#L124" id="L124wa4> 1034               return -<4 href403="+code=loff02" id="L102" class="line" name="L1024> 1044       }
ms">retval == s="hrsultef="+code=file"efsultss="Ih" c>115" id="L115" class="line" name="L6">4>51044                      re4le-sr40 href="+code=retval" gotoe *4>61044              if (4>81044              if (srom_devicecAddeinitef="+code=file"cAddeinitRVAL""="sref">srom_dedummces" of="+code=srom_devices" cclass="re"="sref">srom_dedummces" /spsef="+code=file"r/til/spsm.>r3char/til="co="de" cc#L124" id="L124wa4>91044                      u32 r="s>hv_devhdl,THIS_MODULu32 r="s"="sref">srom_dedummces" /spsef="+code=file"r/til/spsm.>rchar/til="co="de" cc#L124" id="L124wa4>11004cclude <u32 hv_devhdl,cAddeadhref="+code=hv_dcAddeadhRVAL""="sref">srom_dedummces" of="+code=srom_devices" cclass="re class="sref">Sf="+code=srom_deviclass="retval);
115" id="L115" class="line" name="L6">4> 1134                        4     41+code=EIO" class="sregotoe *4> 1154                       r4turn 4154> 1164               if ((hv_devhdl,cde=s_c cla href="+code=hv_cde=s_c cla RVAL" class="sref">STHIS_MODUL3char/til="co="de" cc#L124" id="L124wa4> 1174                       c4ntinu417val" class="!uf == s="IS_ERRef="drivers/chaIS_ERRRVAL" class="sref">S(hdl"ode=s+code=srom_devices" cde=sss=")L119" id="L119" class="line" name="L1194>81044               if (hv_devhdl,efsultef="+code=file"efsultss="IO<>hv_devhdl,PTR_ERRef="drivers/chaPTR_ERRRVAL" class="sref">S(hdl"ode=s+code=srom_devices" cde=sss=")char/til="co="de" cc#L124" id="L124wa4>91044                       <4 href41+code=msleep" class="gotoe *u32 pr_err(,f="_attrref="drivers/chae-s_attrrss="r"sref">hv_deviverff="_f="_attrref="drivers/char/tile-s_attrrss="char/til="co="de" cc#L124" id="L124wa4> 1024                pr_err(,f="a href="+code=file"e-sa hrs">rr"sref">hv_deviverff="_f="a href="+code=file"r/tile-sa hrs">rchar/til="co="de" cc#L124" id="L124wa4> 1134               return -<4 href4234> 1154
Si+code=srom_devii,sasc#L12  class="sref">Si+code=srom_devii,sasch" c>tval);
_srom_wra hrefsultef="+code=file"efsultss="IO<>hv_devhdl,r/tils">Ep_minoref="drivers/charreles">Ep_minors">re>hv_devhdl,ces" cla-srref="drivers/char/tile-s-srrss="=+atval ==vicei+code=srom_devii,sasretval);
4> 1174span class="comment">/**4/span42
retval == s="hrsultef="+code=file"efsultss="Ih" c>115" id="L115" class="line" name="L6">4> 1284span class="comment"> * 4rom_o42e=retval" class="srefvers/chagotoe *rchar/til="co="de" cc#L124" id="L124wa4>91044span class="comment"> * 4inode429 * 4filp:43c#L51" id="L51" class="line" name="L511">4> 1314span class="comment"> *<4span>431"sref">u32EIO<0char/til="co="de" cc#L124" id="L124wa4> 1024span class="comment"> * 4eturn43c#L83" id="L83" class="line" name="L813">4> 1334span class="comment"> */4/span43+code *r:" id="L83" class="line" name="L813">4> 1044tatic int Si+code=srom_devii,sasc#L12  class="sref">Si+code=srom_devii,sasch" c>tval);
4> 1154
(,f="-sr_ded\noyef="+code=file"e-s-sr_ded\noyRVAL" class="sref">S(hdl"ode=s+code=srom_devices" cde=sss="retval);
S(hdl"majoref="drivers/charrelemajorss="se *4> 1264 class="line" name="L1354> 13543e=retval" claleep(S(hdl"ode=s+code=srom_devices" cde=sss=")char/til="co="de" cc#L124" id="L124wa4> 1174nclude <r:" id="L83" class="line" name="L813">4> 1284nclude <srom_devicecAddedehref="+code=HV_VcAddedehRVAL""="sref">srom_dedummces" of="+code=srom_devices" cclass=")char/til="co="de" cc#L124" id="L124wa4>91044nclude <r:" id="L83" class="line" name="L813">4 40#4nclude <u32 Sf="+code=srom_deviclass="retval);
44s/cha *4  1024pan class="comment">1/*<4s1an>442re>hv_devhdl,ces" cla-srref="drivers/char/tile-s-srrss=")char/til="co="de" cc#L124" id="L124wa4  1334pan class="comment">1 * 4i1e o44+code=EIO" clf">EIO;
1 * 4o1tha44c#L6502" id="L102" class="line" name="L1024> 1354pan class="comment">1 * 4y1erv44.c#L14" id="L124" class="line" name="L0">4  1264pan class="comment">1 * 4 1eco44, so if we allowed the usep/ns=rrelecleanupeR4  1174pan class="comment">1 * 4n1ire44
re>buf15" id="L115" class="line" name="L6">4> 128#4pan class="comment">1 */4/14m_44e=ret19" id="L119" class="line" name="L1194 39#4efine hv_devhdl,i+code=srom_devii,saschar/til="co="de" cc#L124" id="L124wa4 50
4a href="drivers/char1/ti4e15=m450"sref">u32Si+code=srom_devii,sasc#L12  class="sref">Si+code=srom_devii,sasch" c>tval);
4 51<4pan class="comment">1/*<4s15iv45s/char/tile-srom.c#L1_err(,f="-sr_ded\noyef="+code=file"e-s-sr_ded\noyRVAL" class="sref">S(hdl"ode=s+code=srom_devices" cde=sss="retval);
S(hdl"majoref="drivers/charrelemajorss="se *1 * 4h15ro452S(hdl"ode=s+code=srom_devices" cde=sss=")char/til="co="de" cc#L124" id="L124wa4>43<4pan class="comment">1 */4/15ef453srom_dedummces" of="+code=srom_devices" cclass=")char/til="co="de" cc#L124" id="L124wa4 54
4a href="drivers/char1/ti4e15ar45ile-srom.">msleep(SMKDEV+code=srom_deviMKDEVRVAL" class="sref">S(hdl"majoref="drivers/charrelemajorss="se03retval);
1/*<4s15n 45 href="+code=leep(re>hv_devhdl,ces" cla-srref="drivers/char/tile-s-srrss=")char/til="co="de" cc#L124" id="L124wa4  >
<4pan class="comment">1 * 4n15+c45e=ret02" id="L102" class="line" name="L1024 47<4pan class="comment">1 */4/15la45c#L78" id="L78" class="line" name="L78"> 4 48#4efine re>hv_devhdl,ces" initef="+code=file"rreleinitRVAL)char/til="co="de" cc#L124" id="L124wa4 39#4a href="drivers/char1/ti4e15la45c#L60 *S(hdl"odeanup+code=srom_devices" cdeanups">r)char/til="co="de" cc#L124" id="L124wa4 60<4pan class="comment">1/*<4s16ro46c#L51


Th.LXR theunityss="sethis experie usal de" -sr by ar/til="cmailto:lx=@comux.no">lx=@comux.noss=".
lx=.comux.no kindly hostfd by ar/til="chttp://www.redpill-compro.no">Redpill Lompro ASss="seprovidf=byteLomuxessreulting and operae-srv sers-srr since 1995.