From mboxrd@z Thu Jan 1 00:00:00 1970 From: varun mahajan Subject: New style I2C driver for KXSD9 accelerometer Date: Sat, 20 Sep 2008 08:51:58 +0530 (IST) Message-ID: <20125.80062.qm@web7902.mail.in.yahoo.com> Reply-To: invincible_6-/E1597aS9LQxFYw1CcD5bw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2695265474166393901==" Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org Errors-To: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org To: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org List-Id: linux-i2c@vger.kernel.org --===============2695265474166393901== Content-Type: multipart/alternative; boundary="0-1166582833-1221880918=:80062" --0-1166582833-1221880918=:80062 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, =C2=A0 I m implementing a driver for accelerometer KXSD9 in linux kernel 2.6.24.7 = for OMAP-3430. KXSD9 sensor will be connected to the i2c bus so it will be = an i2c client. =C2=A0 I m implementing a new style driver, so following are the steps that I m fo= llowing: =C2=A0 1. Putting the device info (busnum, address, irq) in the board specific ini= tialization code. From this the i2c-core will create a client for my device= when the corresponding bus adapter (i2c_adapter) is registered. =C2=A0 2. I m implementing the following i2c_driver for my device =C2=A0 struct i2c_driver KXSD9_i2c_driver =3D { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .driver = =3D { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .name =3D "= KXSD9_driver", =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .probe = =3D KXSD9_probe, /* this will do the device initialization */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .remove = =3D KXSD9_remove, =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .shutdow= n =3D KXSD9_shutdown, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .suspend= =3D KXSD9_suspend, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .resume = =3D KXSD9_resume, }; =C2=A0 3. My requirement is that I need to export the file operations (specific io= ctl commands) to the user space. I am not sure how it has to be done from t= his driver???? =C2=A0 I thought of the following approach: Registering a misc device to export the file operations =C2=A0 int __init KXSD9_driver_init() { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*Provide /dev= interface to user space and export the file=C2=A0=C2=A0=20 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 op= erations */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 misc_register(= &KXSD9_misc_device); =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*Request the = IRQ and install the interrupt handler*/ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 request_irq(..= KXSD9_IRQ . .); =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*Add the i2c_= driver*/ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i2c_add_driver= (&KXSD9_i2c_driver); } =C2=A0 Is this the correct way of doing it???????? Or the file operations should b= e exported using some other method in case of i2c_drivers???? =C2=A0 Your reply will be highly helpful=E2=80=A6 Thanks in advance=E2=80=A6. =C2=A0 Varun=0A=0A=0A Download prohibited? No problem. CHAT from any browser,= without download. Go to http://in.webmessenger.yahoo.com/ --0-1166582833-1221880918=:80062 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Hi,

 

I m implementing a driver for accelerometer KXSD9 in linux = kernel 2.6.24.7 for OMAP-3430. KXSD9 sensor will be connected to the i2c bu= s so it will be an i2c client.

 

I m implementing a new style driver, so following are the s= teps that I m following:

 

1. Putting the device info (busnum, address, irq) in the bo= ard specific initialization code. From this the i2c-core will create a clie= nt for my device when the corresponding bus adapter (i2c_adapter) is regist= ered.

 

2. I m implementing the following i2c_driver for my device<= /FONT>

 

struct i2c_driver KXSD9_i2c_driver =3D

{

   &n= bsp;        .driver =3D {<= /FONT>

   &n= bsp;            = ;        .name =3D "KXSD9_driver"= ,

   &n= bsp;        },

    &n= bsp;      

   &n= bsp;        .probe =3D KXSD9_prob= e, /* this will do the device initialization */

   &n= bsp;        .remove =3D KXSD9_rem= ove,

 

   &n= bsp;        .shutdown =3D KXSD9_s= hutdown,

   &n= bsp;        .suspend =3D KXSD9_su= spend,

   &n= bsp;        .resume =3D KXSD9_res= ume,

};

 

3. My requirement is that I need to export the file operati= ons (specific ioctl commands) to the user space. I am not sure how it has t= o be done from this driver????

 

I thought of the following approach:

Registering a misc device to export the file operations

 

int __init KXSD9_driver_init()

{

   &= nbsp;       /*Provide /dev interface t= o user space and export the file &nb= sp;

   &= nbsp;         operations */<= /FONT>

   &= nbsp;       misc_register(&KXSD9_m= isc_device);

 

   &= nbsp;       /*Request the IRQ and inst= all the interrupt handler*/

   &= nbsp;       request_irq(.. KXSD9_IRQ .= .);

 

   &= nbsp;       /*Add the i2c_driver*/

   &= nbsp;       i2c_add_driver(&KXSD9_= i2c_driver);

}

 

Is this the correct way of doing it???????? Or the file ope= rations should be exported using some other method in case of i2c_drivers??= ??

 

Your reply will be highly helpful=E2=80=A6 Thanks in advanc= e=E2=80=A6.

 

Varun


=0A=0A=0A=0A <= !--2-->
Unlimited freedom, unlimited storage. Get it now --0-1166582833-1221880918=:80062-- --===============2695265474166393901== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ i2c mailing list i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org http://lists.lm-sensors.org/mailman/listinfo/i2c --===============2695265474166393901==--