lkml.org 
[lkml]   [2008]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH][resubmit] TPM: update char dev BKL pushdown
    From
    Date
    It was all about this section:

    > chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8),
    GFP_KERNEL);
    > if (chip->data_buffer == NULL) {
    > - chip->num_opens--;
    > + atomic_set(&chip->is_open, 0);
    > put_device(chip->dev);

    num_opens wasn't protected by driver_lock, so we made num_opens/is_open
    atomic_t. But an int seems too much for just a flag (as Serge pointed),
    and the code would be cleaner if we make only this line atomic, by using
    test_and_set_bit(). Thanks Alan.
    I'll rewrite it.

    Rajiv


    On Tue, 2008-08-26 at 22:19 -0500, Serge E. Hallyn wrote:
    > Quoting Alan Cox (alan@lxorguk.ukuu.org.uk):
    > > > + atomic_set(&chip->is_open, 1);
    > > > + get_device(chip->dev); /* protect from chip disappearing */
    > >
    > > Why not just use test_and_set_bit() ? You seem to be abusing atomic_t to
    > > achieve this.
    >
    > Good point. Or heck just make it a simple flag. Earlier I thought there
    > was a place where driver_lock was taken just to do num_opens--, and so
    > replacing the int num_opens with an atomic_t seemed worthwhile. But since
    > is_open is a boolean and now seems to be always protected by driver_lock,
    > a flag seems best.
    >
    > -serge
    > --
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.kernel.org
    > More majordomo info at http://vger.kernel.org/majordomo-info.html
    > Please read the FAQ at http://www.tux.org/lkml/



    \
     
     \ /
      Last update: 2008-08-27 16:39    [W:0.024 / U:0.032 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site