All of lore.kernel.org
 help / color / mirror / Atom feed
* 0 bit shift
@ 2017-03-29 22:59 Tobin C. Harding
  2017-03-29 23:57 ` valdis.kletnieks at vt.edu
  0 siblings, 1 reply; 3+ messages in thread
From: Tobin C. Harding @ 2017-03-29 22:59 UTC (permalink / raw)
  To: kernelnewbies

What is the reason for the zero bit shift in this code please?

#define SDIO_STATE_PRESENT	(1<<0)		/* present in sysfs */

file: include/linux/mmc/sdio_func.h

thanks,
Tobin.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 0 bit shift
  2017-03-29 22:59 0 bit shift Tobin C. Harding
@ 2017-03-29 23:57 ` valdis.kletnieks at vt.edu
  2017-03-30  0:39   ` Tobin C. Harding
  0 siblings, 1 reply; 3+ messages in thread
From: valdis.kletnieks at vt.edu @ 2017-03-29 23:57 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 30 Mar 2017 09:59:44 +1100, "Tobin C. Harding" said:
> What is the reason for the zero bit shift in this code please?
>
> #define SDIO_STATE_PRESENT	(1<<0)		/* present in sysfs */
>
> file: include/linux/mmc/sdio_func.h

Most likely, to indicate that it's a bitmask in the 'unsigned int state'
in the line above, rather than an integer.

See the other 2 uses of the flag in-tree:

[/usr/src/linux-next] git grep SDIO_STATE_PRESENT
include/linux/mmc/sdio_func.h:#define SDIO_STATE_PRESENT        (1<<0)          /* present in sysfs */
include/linux/mmc/sdio_func.h:#define sdio_func_present(f)      ((f)->state & SDIO_STATE_PRESENT)
include/linux/mmc/sdio_func.h:#define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 484 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170329/afc9f5c4/attachment.bin 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 0 bit shift
  2017-03-29 23:57 ` valdis.kletnieks at vt.edu
@ 2017-03-30  0:39   ` Tobin C. Harding
  0 siblings, 0 replies; 3+ messages in thread
From: Tobin C. Harding @ 2017-03-30  0:39 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Mar 29, 2017 at 07:57:50PM -0400, valdis.kletnieks at vt.edu wrote:
> On Thu, 30 Mar 2017 09:59:44 +1100, "Tobin C. Harding" said:
> > What is the reason for the zero bit shift in this code please?
> >
> > #define SDIO_STATE_PRESENT	(1<<0)		/* present in sysfs */
> >
> > file: include/linux/mmc/sdio_func.h
> 
> Most likely, to indicate that it's a bitmask in the 'unsigned int state'
> in the line above, rather than an integer.
> 
> See the other 2 uses of the flag in-tree:
> 
> [/usr/src/linux-next] git grep SDIO_STATE_PRESENT
> include/linux/mmc/sdio_func.h:#define SDIO_STATE_PRESENT        (1<<0)          /* present in sysfs */
> include/linux/mmc/sdio_func.h:#define sdio_func_present(f)      ((f)->state & SDIO_STATE_PRESENT)
> include/linux/mmc/sdio_func.h:#define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
> 

Awesome, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-30  0:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 22:59 0 bit shift Tobin C. Harding
2017-03-29 23:57 ` valdis.kletnieks at vt.edu
2017-03-30  0:39   ` Tobin C. Harding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.