* Question about i2c_xxx function on CONFIG_I2C
@ 2011-06-27 7:00 kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ
[not found] ` <87aad3bvyf.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ @ 2011-06-27 7:00 UTC (permalink / raw)
To: Linux-I2C
Dear all
I'm using i2c_xxx function on some board.
And sometimes I need very small kernel which doesn't need CONFIG_I2C.
But then (.config doesn't have CONFIG_I2C), the compile will fail.
like this
error: implicit declaration of function 'i2c_get_adapter'
error: implicit declaration of function 'i2c_transfer'
In this case, should I use #ifdef CONFIG_I2C in my code to solve this compile issue ?
Or is below #else in i2c.h good idea ?
--- i2c.h ---------
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
...
extern struct i2c_adapter *i2c_get_adapter(int nr);
...
#else
...
#define i2c_get_adapter(nr) NULL
...
#endif
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <87aad3bvyf.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>]
* Re: Question about i2c_xxx function on CONFIG_I2C [not found] ` <87aad3bvyf.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> @ 2011-06-27 11:30 ` Jean Delvare [not found] ` <20110627133056.1379854a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org> 2011-06-27 14:04 ` Zhang, Shijie 1 sibling, 1 reply; 4+ messages in thread From: Jean Delvare @ 2011-06-27 11:30 UTC (permalink / raw) To: kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ; +Cc: Linux-I2C Hi Morimoto, On Mon, 27 Jun 2011 16:00:08 +0900, kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org wrote: > I'm using i2c_xxx function on some board. > And sometimes I need very small kernel which doesn't need CONFIG_I2C. > > But then (.config doesn't have CONFIG_I2C), the compile will fail. > like this > > error: implicit declaration of function 'i2c_get_adapter' > error: implicit declaration of function 'i2c_transfer' > > In this case, should I use #ifdef CONFIG_I2C in my code to solve this compile issue ? Yes. > Or is below #else in i2c.h good idea ? > > --- i2c.h --------- > #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) > ... > extern struct i2c_adapter *i2c_get_adapter(int nr); > ... > #else > ... > #define i2c_get_adapter(nr) NULL > ... > #endif I don't think this is a good idea in general. If the kernel lacks I2C support, and your code uses it, then this is dead code, and you're much better excluding that code completely from your build. Most likely you'll be able to drop whole functions. I wouldn't count on the compiler to optimize it all properly, and you said you want a very small kernel. Of course we could make better comments if we could see your actual code. Maybe some ifdef magic in i2c.h would make sense for a few items, as we already do for i2c_register_board_info for example. -- Jean Delvare ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20110627133056.1379854a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>]
* Re: Question about i2c_xxx function on CONFIG_I2C [not found] ` <20110627133056.1379854a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org> @ 2011-06-28 3:37 ` kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w 0 siblings, 0 replies; 4+ messages in thread From: kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w @ 2011-06-28 3:37 UTC (permalink / raw) To: Jean Delvare; +Cc: Linux-I2C Dear Jean Thank you for your advice > I don't think this is a good idea in general. If the kernel lacks I2C > support, and your code uses it, then this is dead code, and you're much > better excluding that code completely from your build. Most likely > you'll be able to drop whole functions. I wouldn't count on the > compiler to optimize it all properly, and you said you want a very > small kernel. > > Of course we could make better comments if we could see your actual > code. Maybe some ifdef magic in i2c.h would make sense for a few items, > as we already do for i2c_register_board_info for example. I understand, thank you. I use #ifdef for it. Best regards --- Kuninori Morimoto ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Question about i2c_xxx function on CONFIG_I2C [not found] ` <87aad3bvyf.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 2011-06-27 11:30 ` Jean Delvare @ 2011-06-27 14:04 ` Zhang, Shijie 1 sibling, 0 replies; 4+ messages in thread From: Zhang, Shijie @ 2011-06-27 14:04 UTC (permalink / raw) To: kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org, Linux-I2C Hi, I think you can config the kernel using make menuconfig command, go to Device Driver--->I2C Suppport Check what you want to disselect. -----Original Message----- From: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org] On Behalf Of kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org Sent: Monday, June 27, 2011 3:00 PM To: Linux-I2C Subject: Question about i2c_xxx function on CONFIG_I2C Dear all I'm using i2c_xxx function on some board. And sometimes I need very small kernel which doesn't need CONFIG_I2C. But then (.config doesn't have CONFIG_I2C), the compile will fail. like this error: implicit declaration of function 'i2c_get_adapter' error: implicit declaration of function 'i2c_transfer' In this case, should I use #ifdef CONFIG_I2C in my code to solve this compile issue ? Or is below #else in i2c.h good idea ? --- i2c.h --------- #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) ... extern struct i2c_adapter *i2c_get_adapter(int nr); ... #else ... #define i2c_get_adapter(nr) NULL ... #endif Best regards --- Kuninori Morimoto -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-28 3:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-27 7:00 Question about i2c_xxx function on CONFIG_I2C kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ
[not found] ` <87aad3bvyf.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2011-06-27 11:30 ` Jean Delvare
[not found] ` <20110627133056.1379854a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-06-28 3:37 ` kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w
2011-06-27 14:04 ` Zhang, Shijie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox